views:

219

answers:

1

I have a number of custom table cells and views that I built using interface builder

In interface builder, everything is set up similarly. There is a table cell and a couple other UILabels and a background image

Object owner if the nib is NSObject Class for the table cell is the name of the class for my table cell

Here is how I create the table cell in my code:

SectionedSwitchTableCell *cell = nil;
NSArray *nibs = [[NSBundle mainBundle] loadNibNamed:kSectionedSwitchTableCellIdentifier owner:owner options:nil];
for(id currentObject in nibs)
{
    if([currentObject isKindOfClass:[SectionedSwitchTableCell class]])
    {
        cell = (SectionedSwitchTableCell *)currentObject;
        break;
    }
}
return cell;

For my custom table headers I have this

    NSArray *nibs = [[NSBundle mainBundle] loadNibNamed:@"CustomTableHeader" owner:self options:nil];
    for(id currentObject in nibs)
    {
        if([currentObject isKindOfClass:[CustomTableHeader class]])
        {
           return header
        }
    }

In my .h and .m files for the custom view, I have IBOutlet, @property set up for everything except for the background image UIImageView. Everything that has the IBOutlet and @property are also @synthesized and released in the .m file.

Leaks is showing that I have memory leaks with CALayer when I create these custom view objects. Am I doing something wrong here when I create these custom view objects? I'm kind of tearing my hair out trying to figure out where these leaks are coming from.

As a side note, I have a UIImageView background image defined in these custom views but I didn't define properties and IBOutlets in my .h and .m files. Defining them doesn't make a difference when I run it through Leaks but just wanted to confirm if I'm doing the right thing.

Any input would be super helpful. Thanks :)

A: 

The above code showing you memory leaks because of

NSArray *nibs = [[NSBundle mainBundle] loadNibNamed:kSectionedSwitchTableCellIdentifier owner:owner options:nil]; this line. when tableViewObjectAtIndexPath method is trigger the NSArray allocating new memory and it will happening number of time tableViewObjectAtIndexPath method override.

RRB