繁体   English   中英

不了解潜在的泄漏

[英]Don't understand the potential leak

我在xcode中使用了Analyze函数,并且已经修复了除此以外的所有内容。

我想知道“分配的对象的潜在泄漏”的确切含义是什么,并且它引用了这些行。

- (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.

在这个空白的结尾,我说:

    [[self navigationController] pushViewController:type_prod animated:YES];
[type_prod release];

那为什么说如果我在最后释放它,则可能存在泄漏?

我认为type_prod是保留的属性。 您需要使用self.type_prod = nil在dealloc方法中释放它。

还要确保在所有情况下都执行最后的发布。 立即释放它比较安全:

self.type_prod = [[[ProductType alloc] initWithNibName:@"ProductType" bundle:[NSBundle mainBundle]] autorelease];

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM