我正在关注这个[博客] [1],用于将数据从表格视图中的自定义单元格传递到视图控制器。自定义单元格从响应中获取数据,我必须在自定义单元格中显示一些数据,并在详细信息视图控制器中显示其余数据。任何人都可以确定我的代码中实际问题的来源吗?从segue传递数据。
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:@"ShowDetail"]) {
//Do something
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
ShowViewController *destViewController = segue.destinationViewController;
destViewController.tites = [_Title objectAtIndex:indexPath.row];
destViewController.prce = [_Price objectAtIndex:indexPath.row];
destViewController.ara = [_LandArea objectAtIndex:indexPath.row];
destViewController.phon = [_Phone objectAtIndex:indexPath.row];
destViewController.citi = [_City objectAtIndex:indexPath.row];
destViewController.loc = [_location objectAtIndex:indexPath.row];
destViewController.tye = [_type objectAtIndex:indexPath.row];
destViewController.Idss = [_Id objectAtIndex:indexPath.row];
destViewController.nam = [_name objectAtIndex:indexPath.row];
destViewController.emal = [_email objectAtIndex:indexPath.row];
destViewController.roomss = [_rooms objectAtIndex:indexPath.row];
destViewController.wash = [_washroom objectAtIndex:indexPath.row];
destViewController.flloors = [_floor objectAtIndex:indexPath.row];
destViewController.stat = [_status objectAtIndex:indexPath.row];
destViewController.descrp = [_descrip objectAtIndex:indexPath.row];
destViewController.countryy = [_country objectAtIndex:indexPath.row];
}
}
这是我点击单元格时遇到的错误。
由于未捕获的异常'NSUnknownKeyException'而终止应用, 原因:'[ setValue:forUndefinedKey:]:此类不是键值 符合编码的密钥ID。'第一次抛出调用堆栈:
这是我的ShowViewcontroller.h文件。
更改了代码。
答案 0 :(得分:2)
您可能已删除outlet
从storyboard
到ViewController
的{{1}}连接
请检查您的插座是否正确连接。 ⚠️
必须首先创建id
属性,并在showViewController
答案 1 :(得分:0)
检查ShowViewController中的属性,因为destViewController.Idss(颜色显示错误)
@property(nonatomic,strong) NSString *Idss; // Make as this and
@synthesize Idss
并且还更改[_Id objectAtIndex:indexPath.row] //将_id数组名称替换为其他名称