fuzzygoat
fuzzygoat

Reputation: 26223

No return value from configureCall:atIndexPath:?

I am a little puzzled about what is going on with the cell object being passed into configureCall:atIndexPath: I can see whats happening but find it strange that configureCall:atIndexPath: does not return a UITableViewCell as a return value.

- (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]];
}

Upvotes: 0

Views: 52

Answers (1)

Dan F
Dan F

Reputation: 17732

It doesn't need to return an object, the cell object that is passed in is being modified in place. This way, the configureCell method does not need to allocate or manage objects in any way, it simply needs to do what it needs to to the passed in cell that is already provided by the caller

Upvotes: 1

Related Questions