【问题标题】:ARC semantic Issue No visible @interface for 'UITableView' declares the selector 'cellForRowAtIndexPath:'ARC语义问题“UITableView”没有可见的@interface声明选择器“cellForRowAtIndexPath:”
【发布时间】:2013-10-09 12:15:50
【问题描述】:

我创建一个新项目,选择 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];

【问题讨论】:

    标签: iphone ios ios7 xcode5


    【解决方案1】:

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

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

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

    希望有帮助!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-10-17
      • 2013-05-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多