loading custom view using loadNibNamed showing memory leaks

Posted by user307550 on Stack Overflow See other posts from Stack Overflow or by user307550
Published on 2010-05-20T04:38:51Z Indexed on 2010/05/20 4:40 UTC
Read the original article Hit count: 319

Filed under:
|
|

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 :)

© Stack Overflow or respective owner

Related posts about iphone

Related posts about tablecell