1

我创建一个新项目,选择 Master-Detail Application ,然后选择“使用核心数据”,然后构建新项目。(XCode 5.0)此错误:ARC语义问题“UITableView”没有可见的@interface声明选择器“cellForRowAtIndexPath:”

- (void)controller:(NSFetchedResultsController *)controller didChangeObject:(id)anObject
   atIndexPath:(NSIndexPath *)indexPath forChangeType:(NSFetchedResultsChangeType)type
  newIndexPath:(NSIndexPath *)newIndexPath
{
    UITableView *tableView = self.tableView;

    switch(type) {
        case NSFetchedResultsChangeInsert:
        [tableView insertRowsAtIndexPaths:@[newIndexPath] withRowAnimation:UITableViewRowAnimationFade];
        break;

    case NSFetchedResultsChangeDelete:
        [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
        break;

    case NSFetchedResultsChangeUpdate:
        [self configureCell:[tableView cellForRowAtIndexPath:indexPath] atIndexPath:indexPath];
        break;

    case NSFetchedResultsChangeMove:
        [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
        [tableView insertRowsAtIndexPaths:@[newIndexPath] withRowAnimation:UITableViewRowAnimationFade];
        break;
    }
}

错误:

 [self configureCell:[tableView cellForRowAtIndexPath:indexPath] atIndexPath:indexPath];
4

1 回答 1

1

那是因为它是表视图数据源而不是表视图的方法。此外,该UITableViewDataSource方法的正确签名是tableView:cellForRowAtIndexPath:而不是cellForRowAtIndexPath:

所以你的电话实际上应该是,

 [self configureCell:[datasource tableView:tableView cellForRowAtIndexPath:indexPath] atIndexPath:indexPath];
 // If datasource is self, replace with self

希望有帮助!

于 2013-10-09T12:42:09.080 回答