I was using the Analyze function in xcode, and I’ve fixed everything except this one.
I’m wondering what this exactly means of a “potential leak of an object allocated”, and it refers to these lines.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
self.type_prod = [[ProductType alloc] initWithNibName:@"ProductType" bundle:[NSBundle mainBundle]];
NSString *prodtitle = [product objectAtIndex:indexPath.row];
type_prod.prodtitle = prodtitle;
etc etc.
At the end of this void I say:
[[self navigationController] pushViewController:type_prod animated:YES];
[type_prod release];
So why does it say there is a potential leak if I release it at the end?
I assume type_prod is a retained property. You need to release it in the dealloc method with
self.type_prod = nil.Also make sure the release at the end is executed in all cases. It is safer to autorelease it right away: