When using Xcode’s Analyze tool I receive the following memory leak warning for this UITableView allocation –
Object leaked: allocated object is not referenced later in this execution path and has a retain count of +1
self.contentTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 320, 300) style:UITableViewStyleGrouped];
self.contentTableView.delegate = self;
self.contentTableView.dataSource = self;
self.contentTableView.scrollEnabled = NO;
self.contentTableView.backgroundColor = [AppDelegate appMainColor];
self.contentTableView.separatorColor = [UIColor whiteColor];
self.contentTableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
[self.view addSubview:self.contentTableView];
Anyone has encountered this warning? solution?
Thanks!
Ok, this a guess. I havent worked on legacy targets for a long while. I have been deploying on the later targets. But you can either use the
autoreleaseor manually release theUITableView. Something like this may work,OR if you are using a property, then release inside your
deallocmethod,NOTE: I havent worked with non-ARC environment for a long time and my syntax might (most likely) be wrong and you have to work out syntax issues.