2012-08-06 23 views
0

我對傳遞給configureCall的單元對象發生了什麼感到有些困惑:atIndexPath:我可以看到發生了什麼,但發現它奇怪configureCall:atIndexPath:不返回一個UITableViewCell作爲返回值。從configureCall沒有返回值:atIndexPath:?

- (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

它不需要返回對象,正在修改傳入的cell對象。通過這種方式,configureCell方法不需要以任何方式分配或管理對象,它只需執行所需的功能,以便通過調用者提供的傳入單元格

+0

感謝丹,我只是好奇。 – fuzzygoat 2012-08-06 18:27:07