Reputation: 26223
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
Reputation: 94834
You are correct, the FGCustomCell is allocated by the loading of the nib and is created autoreleased.
Upvotes: 1