When do custom cells from nib release
We dont allocate the nib based view so there seems no point in releasing them as开发者_如何学Python we get the view from bundle.I have a scenario where i have custom cells made from nib.Even when i release the tableview containing the UITableView cell the cell object stays in the memory.I havent retained it anywhere else.I would appreciate any answers thanks
When you get the object from the bundle it assigns it to an IBOutlet instance variable. You need to release the instance in dealloc in the usual way. This is how I do it,
in - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
//get a new cell instance from the xib
[[NSBundle mainBundle] loadNibNamed:@"ASEventTableViewCell" owner:self options:nil];
//get the object from the outlet
cell = [self eventsTableViewCell];
The in viewDidUnload,
self.eventsTableViewCell=nil;
And dealloc
[eventsTableViewCell release];
精彩评论