configureCall没有返回值:atIndexPath:?

时间:2012-08-06 18:18:42

标签: iphone objective-c cocoa-touch

我对于传递给configureCall的单元格对象发生了什么感到有点困惑:atIndexPath:我可以看到发生了什么但发现却奇怪的是:configureCall:atIndexPath:不会返回UITableViewCell作为返回值。

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *cellID = @"PLANETCELL_ID";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if(cell == nil) ...

    // POPULATE CELL NEW
    [self configureCell:cell atIndexPath:indexPath];
    return cell;
}

- (void)configureCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath {
    Planet *managedPlanet = [[self fetchedResultsController] objectAtIndexPath:indexPath];
    [[cell textLabel] setText:[managedPlanet name]];
    [[cell detailTextLabel] setText:[managedPlanet type]];
}

1 个答案:

答案 0 :(得分:1)

它不需要返回一个对象,传入的cell对象正在被修改。这样,configureCell方法不需要以任何方式分配或管理对象,它只需要对调用者已经提供的传入单元格执行所需操作