Why do I have a memory leaking with ARC enabled(highlighted in bold)?
I have CustomCell.m
+(CustomCell*)cell
{
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
NSArray *nib =[[NSBundle mainBundle] loadNibNamed:@"CustomCell_iPhone" owner:self options:nil];
return [nib objectAtIndex:0];
} else {
NSArray *nib =[[NSBundle mainBundle] loadNibNamed:@"CustomCell_iPad" owner:self options:nil]; **//leaking 100%**
return [nib objectAtIndex:0];
}
}
In my tableview conteroller:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
cell=[CustomCell cell]; **// 100% leaking**
...
}
So, two things. One, I gather you’re creating this cell in a .xib file. Set the reuse identifier on the cell in IB. Then, instead of this CustomCell class method, unload the nib in tableView:cellForRowAtIndexPath:, like this:
The second thing is that by trying to dequeue a reusable cell first, you will get much much better performance.