IndexPathForSelectedRow返回null

时间:2012-06-19 21:39:52

标签: objective-c uitableview nsfetchedresultscontroller nsindexpath

我使用fetchresultscontroller返回不同的结果(NSDictionaryResultType),每个部分都有多个部分和行。当我使用indexPathForSelectedRow时,它会返回null。这是我的代码:

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{       
    if ([segue.identifier isEqualToString:@"toDetailViewSeg"]){
        WLDetailTableViewController *detailController =segue.destinationViewController;
        WeightLiftingInfo *theInfo = [[_fetchedResultsController fetchedObjects] objectAtIndex:self.tableView.indexPathForSelectedRow.row];
        detailController.muscleGroupInfo = [theInfo valueForKey:@"muscleGroup"];
        detailController.specificExerciseInfo = [theInfo valueForKey:@"specificExercise"];
        detailController.managedObjectContext = _managedObjectContext;
    }

}

如何获得正确的索引路径??

1 个答案:

答案 0 :(得分:0)

WeightLiftingInfo *theIndo = [_fetchedResultsController objectAtIndexPath:self.tableView.indexPathForSelectedRow];

这似乎就是答案。它提供了正确的索引路径,它看起来像set [x,y]而不是单个整数。 (这是我的解释,这可能是错误的)

相关问题