views:

349

answers:

1

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.

+1  A: 

Are your IBOutlets properties of the cell? If so then release them in MyCustomCell's dealloc method.

Make sure that you are following the guidelines for tableViews and calling dequeueReusableCellWithIdentifier: in tableview:cellForRowAtIndex. The tableView will release your custom cells when it no longer needs them. Assuming that you do not have any other references to your cells (you shouldn't) then dealloc will be called for the cell dequeued by the tableView.

falconcreek
Thanks for your answer. That is pretty much what I've done. The only thing I'm still missing is the part where I set my IBOutlet = nil, which is in the documentation described as to do within (void) viewDidUnload{} which I don't have for my custom UITableViewCell, though.
znq
You can use'[object release], object = nil;'
falconcreek