Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 如何在IOS中处理属性内存管理?_Iphone_Objective C_Ios_Memory Management - Fatal编程技术网

Iphone 如何在IOS中处理属性内存管理?

Iphone 如何在IOS中处理属性内存管理?,iphone,objective-c,ios,memory-management,Iphone,Objective C,Ios,Memory Management,在我的应用程序中,我使用iAction方法将视图更改为另一个视图: -(IBAction)beginGame:(id)sender { NSLog(@"beginGame clicked"); GameView * thisGameView = [[[GameView alloc] init]; MainAppDelegate * delegate = (MainAppDelegate *) [[ UIApplication sharedApplication] dele

在我的应用程序中,我使用iAction方法将视图更改为另一个视图:

-(IBAction)beginGame:(id)sender { NSLog(@"beginGame clicked"); GameView * thisGameView = [[[GameView alloc] init]; MainAppDelegate * delegate = (MainAppDelegate *) [[ UIApplication sharedApplication] delegate]; delegate.window.rootViewController = thisGameView; } -(iAction)beginGame:(id)发件人{ NSLog(@“beginGame clicked”); GameView*此GameView=[[[GameView alloc]init]; MainAppDelegate*委托=(MainAppDelegate*)[[UIApplication sharedApplication]委托]; delegate.window.rootViewController=thisGameView; } 我应该如何处理rootViewController属性和thisGameView内存管理? 现在发布这个游戏视图吗


请在此“beginGame”方法中为我填写一些代码。谢谢。

是的,您应该在将其分配给
delegate.window.rootViewController
后释放
thisGameView
。分配将保留它。

如果
rootViewController
属性是一个保留属性,那么您可以释放
thisGameView
实例a下线后:

delegate.window.rootViewController = thisGameView;

非常感谢,我发现rootViewController是retain:@property(nonatomic,retain)UIViewController*rootViewController\uuuuosx\u AVAILABLE\u start(\uuuuuu MAC\u NA,\uuuuuu IPHONE\u4\u0);//默认值为零这是我在回答中告诉你的:)