Objective c 更改为UITableViewController后的indexPath nil

Objective c 更改为UITableViewController后的indexPath nil,objective-c,uitableview,uistoryboard,Objective C,Uitableview,Uistoryboard,因为我在情节提要中将视图更改为UITableViewController,所以我的indexPath为零。有人能发现错误吗?我使用segues。我已将虚拟单元格从TableViewController连接到新的TableViewController。两者都被推送到UINavigationController中 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

因为我在情节提要中将视图更改为UITableViewController,所以我的indexPath为零。有人能发现错误吗?我使用segues。我已将虚拟单元格从TableViewController连接到新的TableViewController。两者都被推送到UINavigationController中

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [self performSegueWithIdentifier:@"selectCountry" sender:self];
}

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Assume self.view is the table view
    NSIndexPath *path = [self.tableView indexPathForSelectedRow];
    Country *country = (Country *)[fetchedResultsController objectAtIndexPath:path];

    if ([segue.identifier isEqualToString:@"selectCountry"])
    {
        CaveTableViewController *ctvc = [segue destinationViewController];
        ctvc.country = country;
        ctvc.navigationItem.title = country.country;
    }

    [self.tableView deselectRowAtIndexPath:path animated:YES];
}
尝试更改:

NSIndexPath *path = [self.tableView indexPathForSelectedRow];
致:


你好发送方的类型为“CountryTableViewController*”,这是类。如何获取单元格?假设您有一个名为CountryCell的自定义单元格类,则获取的单元格为:CountryCell*cell=[self.tableView CellForRowatineXpath:indexPath];我没有定制的手机。如果你在控制台中放置一个NSLog(@“Index Path:%@::Section:%d::Row:%d”,indexath,indexPath.Section,indexPath.Row)你的代码看起来还可以,indexPath不应该为零,你的单元格在nib文件中是可选的吗?问题已经解决了。。。我清理了这个项目,再次进行了所有链接,它成功了…:/
NSIndexPath *path = [self.tableView indexPathForCell:sender];