繁体   English   中英

更多泄漏代码帮助吗?

[英]More Leaking Code help?

-(IBAction)customizeYourGameButtonClicked:(id)sender {
 [self playHumanHitSound];

 self.customizeYourGameViewController = [[CustomizeYourGameViewController alloc]
    initWithNibName:@"CustomizeYourGameViewController" bundle:nil];

 [self.navigationController
     pushViewController:customizeYourGameViewController animated:YES];
 [customizeYourGameViewController release];
}

无法理解为什么会泄漏。 我将customYourGameViewController设置为属性并对其进行了合成。

看起来customizeYourGameViewController是类的一个属性。 它会保留吗? 如果是这样,customizeYourGameViewController的@synthesized设置器将进行保留,您需要在某个地方释放。

尽管,考虑到这一点,我想知道:为什么customizeYourGameViewController是一个属性? 除非您要与其他地方的控制器通信,否则它应该只是一个局部变量。

-(IBAction)customizeYourGameButtonClicked:(id)sender {
 [self playHumanHitSound];

 id customizeYourGameViewController = [[CustomizeYourGameViewController alloc]
    initWithNibName:@"CustomizeYourGameViewController" bundle:nil];

 [self.navigationController
     pushViewController:customizeYourGameViewController animated:YES];
 [customizeYourGameViewController release];
}

然后删除ivar并删除属性。

您正在分配CustomizeYourGameViewController但没有释放它。 在下面进行更改。

[[[CustomizeYourGameViewController alloc] nitWithNibName:@"CustomizeYourGameViewController" bundle:nil] autorelease];

你可以摆脱决赛

[customizeYourGameViewController release];

我不知道它在做什么(你有一个名为伊娃customizeYourGameViewController ),但它可能不是做什么,你认为它在做什么。

暂无
暂无

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

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