将数据从自定义 tableview 单元格传递到 UIView 控制器

Passing Data from custom tableview cell to UIView controller

我正在关注此 [博客][1],用于将数据从 table 视图中的自定义单元格传递到视图控制器。自定义单元格正在从响应中获取数据,我必须在自定义单元格中显示其中的一些数据,在详细信息视图控制器中显示其余数据。任何人都可以确定我的代码中实际问题出在哪里吗?从 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];

    }
}

这是我在单击单元格时遇到的错误。

Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key id.' First throw call stack:

这是我的 ShowViewcontroller.h 文件。

更改代码。

enter image description here

检查 ShowViewController 中的 属性 因为 destViewController.Idss(颜色显示错误)

 @property(nonatomic,strong) NSString *Idss; // Make as this and 
 @synthesize Idss

同时更改 [_Id objectAtIndex:indexPath.row] // 将 _id 数组名称替换为另一个名称

您可能删除了从 storyboardViewControlleroutlet 连接 请检查您的插座是否连接正确。 ⚠️

必须有一个 id 属性 首先创建并由您删除,在您的 showViewController