If I remove the table, and only navigate from one view to another, everything is fine. But if I add the table and the in the leaks-instruments click on the back btn at that very moment when the leak-instrument is analyzing, I get a growing leak. I get some small leaks QuartzCore mem_alloc. They are initially 8 Bytes each. Next time the leak appears they are 16 etc. Worse is a [NSCFArray copyWithZone:] leak which initially is 128 Bytes. I have been seaking for this leak for days now and I do not understand what the problem is. My whole app is navigating with tables and I assume (but do not actually have a clue) that my leaks are because of those tables... Any ideas?
MACloop
MACloop
Code:
@implementation StartViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
if (self = [super initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil]) {
UIButton *infoButton = [UIButton buttonWithType:UIButtonTypeCustom];
[infoButton setImage:[UIImage imageNamed:@"logo.png"] forState:UIControlStateNormal];
[infoButton addTarget:self action:@selector(openInfo:) forControlEvents:UIControlEventTouchUpInside];
infoButton.showsTouchWhenHighlighted = NO;
infoButton.frame = CGRectMake(0, 0, 65, 50);
UIBarButtonItem *itemForBar = [[UIBarButtonItem alloc]initWithCustomView:infoButton];
self.navigationItem.rightBarButtonItem = itemForBar;
[itemForBar release];
}
return self;
}
- (void) openInfo:(id)sender {
InfoViewController *infoView = [[InfoViewController alloc] initWithNibName:@"InfoViewController" bundle:nil];
[self.navigationController pushViewController:infoView animated:YES];
[infoView release];
}
- (void)viewDidLoad {
[super viewDidLoad];
self.tableView.scrollEnabled = NO;
}
#pragma mark Table view methods
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 5;
}
- (UITableViewCell *)tableView:(UITableView *)t cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
StartTableViewCell *cell = (StartTableViewCell *)[t dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[StartTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
cell.backgroundColor = [UIColor lightGrayColor];
UIView *bg = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 320, 60)];
bg.backgroundColor = selectedBackground;
[cell setSelectedBackgroundView:bg];
[bg release];
switch ([indexPath row]) {
case 0:
[cell setHeadline:@"Test0"];
[cell setTextline:@"Test0"];
[cell setTheBackground:@"Test0.png"];
break;
case 1:
[cell setHeadline:@"Test1"];
[cell setTextline:@"Test1"];
[cell setTheBackground:@"Test1.png"];
break;
case 2:
[cell setHeadline:@"Test2"];
[cell setTextline:@"Test2"];
[cell setTheBackground:@"Test2.png"];
break;
case 3:
[cell setHeadline:@"Test3"];
[cell setTextline:@"Test3"];
[cell setTheBackground:@"Test3.png"];
break;
case 4:
[cell setHeadline:@"Test4"];
[cell setTextline:@"Test4"];
[cell setTheBackground:@"Test4.png"];
break;
default:
break;
}
return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
return 61;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
switch ([indexPath row]) {
case 0:
a = [[aObjectViewController alloc] initWithNibName:@"aObjectViewController" bundle:nil];
[self.navigationController pushViewController:a animated:YES];
[a release];
break;
case 1:
b = [[bObjectViewController alloc] initWithNibName:@"bObjectViewController" bundle:nil];
[self.navigationController pushViewController:b animated:YES];
[b release];
break;
case 2:
c = [[cObjectViewController alloc] initWithNibName:@"cObjectViewController" bundle:nil];
[self.navigationController pushViewController:c animated:YES];
[c release];
break;
case 3:
d = [[cObjectViewController alloc] initWithNibName:@"dObjectViewController" bundle:nil];
[self.navigationController pushViewController:d animated:YES];
[d release];
break;
case 4:
e = [[eObjectViewController alloc] initWithNibName:@"cObjectViewController" bundle:nil];
[self.navigationController pushViewController:e animated:YES];
[e release];
break;
default:
break;
}
}
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
}
- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)dealloc {
[super dealloc];
}
@end