fuzzygoat
fuzzygoat

Reputation: 26223

Memory management with UITableViewCells from a NIB?

Usually when I setup a UITableViewCell I used the default cellStyles, allocating and autoreleasing the cells as needed. My question is with regards to the memory management in the example below. Where is the FGCustomCell allocated, is it created when I ask for the objects includde in the nib? I am also assuming its autoreleased so the code below is fine?

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    FGCustomCell *customCell = (FGCustomCell *)[tableView dequeueReusableCellWithIdentifier:@"FGCELL_ID"];
    if(customCell == nil) {
        NSArray *nibObjects = [[NSBundle mainBundle] loadNibNamed:@"FGCustomCell" owner:self options:nil];
        for(id eachObject in nibObjects) {
            if([eachObject isKindOfClass:[FGCustomCell class]]) customCell = (FGCustomCell *)eachObject;
        }
    }
    return customCell;
}

Upvotes: 0

Views: 155

Answers (1)

Anomie
Anomie

Reputation: 94834

You are correct, the FGCustomCell is allocated by the loading of the nib and is created autoreleased.

Upvotes: 1

Related Questions