I've gone thru my app using build/analyze and been able to resolve all issues.
but running under leak tool it detects a leak and says it comes from tvc:viewDidLoad where tvc is a tableViewController
it further references NSArray -> sectionlist
it shows a malloc refct=1 then a retain refct=2 then a release refct=1
here is viewDidLoad below followed by the dealloc and the header
I don't see where this is a problem? Am I missing something?
other than the code I've included, the sectionList is only referenced in 2 other places -
in numberOfRowsInSection
return [[self sectionList] count];
in cellForRowAtIndexPath
[[cell textLabel] setText:[[self sectionList] objectAtIndex:indexPath.row]];
is this a red herring? ie; is it a real leak or is the leak tool only capable of showing the alloc but then not showing where the release happens in the dealloc when the tvc is unloaded later?
enter code here
/// code
////////////////////////
// property
@synthesize sectionList = ivSectionList;
/*
*********************************************
build list of sections
*********************************************
*/
- (void)viewDidLoad
{
[super viewDidLoad];
// alloc a local array and init with values
NSArray *sections = [[NSArray alloc] initWithObjects:@"A", @"B", @"C", nil];
// assign local array to tvc ivar
[self setSectionList:sections];
// release local array
[sections release], sections=nil;
}
/*
*********************************************
release ivSectionList
*********************************************
*/
- (void)dealloc
{
[ivsectionList release], ivsectionList=nil;
[super dealloc];
}
//////// header
////////////////////////////////////////
#import <UIKit/UIKit.h>
@interface tvc : UITableViewController
{
NSArray *ivsectionList;
}
@property (nonatomic, retain) NSArray *sectionList;
@end
////////////////////////////////////////