簡體   English   中英

如何處理IOS中的屬性內存管理?

[英]How to deal with a property memory management in IOS?

在我的應用程序中,我有一個IBAction方法將視圖更改為另一個視圖:

-(IBAction)beginGame:(id)sender {
    NSLog(@"beginGame clicked");
    GameView * thisGameView = [[[GameView alloc] init];
    MainAppDelegate * delegate = (MainAppDelegate *) [[ UIApplication sharedApplication] delegate];

    delegate.window.rootViewController = thisGameView;
}

我應該如何處理rootViewController屬性和thisGameView內存管理? 立即發布thisGameView?

請在此“ beginGame”方法中填寫一些代碼。 謝謝。

如果rootViewController屬性是rootViewController屬性,那么您可以在以下行后釋放thisGameView實例:

delegate.window.rootViewController = thisGameView;

是的,你應該釋放thisGameView其分配給后delegate.window.rootViewController 作業將保留它。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM