簡體   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