iPhone: custom UITableViewCell with Interface Builder -> how to release cell objects?

Posted by Stefan Klumpp on Stack Overflow See other posts from Stack Overflow or by Stefan Klumpp
Published on 2010-04-28T18:33:55Z Indexed on 2010/04/28 18:37 UTC
Read the original article Hit count: 299

The official documentation tells me I've to do these 3 things in order to manage the my memory for "nib objects" correctly.

@property (nonatomic, retain) IBOutlet UIUserInterfaceElementClass *anOutlet;

"You should then either synthesize the corresponding accessor methods, or implement them according to the declaration, and (in iPhone OS) release the corresponding variable in dealloc."

- (void)viewDidUnload {
    self.anOutlet = nil;
    [super viewDidUnload];
}

That makes sense for a normal view. However, how am I gonna do that for a UITableView with custom UITableViewCells loaded through a .nib-file?

There the IBOutlets are in MyCustomCell.h (inherited from UITableViewCell), but that is not the place where I load the nib and apply it to the cell instances, because that happens in MyTableView.m

So do I still release the IBOutlets in the dealloc of MyCustomCell.m or do I have to do something in MyTableView.m?

Also MyCustomCell.m doesn't have a - (void)viewDidUnload {} where I can set my IBOutlets to nil, while my MyTableView.m does.

© Stack Overflow or respective owner

Related posts about iphone

Related posts about memory-management