开发者

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];
}

Can't understand why this is leaking. I set 开发者_StackOverflowcustomizeYourGameViewController as a property and synthesized it.


It looks like customizeYourGameViewController is a property on your class. Is it set to retain? If so, the @synthesized setter for customizeYourGameViewController is doing a retain and you'll need to release somewhere.

Although, thinking about this, I'm wondering: Why is customizeYourGameViewController a property? Unless you're communicating with the controller elsewhere, it should just be a local variable.

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

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

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

Then remove the ivar and remove the property.


You are allocating CustomizeYourGameViewController but not releasing it. Makes the changes below.

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

and you can get rid of the final

[customizeYourGameViewController release];

I'm not sure what it's doing (do you have a iVar named customizeYourGameViewController), but it's probably not doing what you think it's doing.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜