[英]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.