Iphone 如何在IOS中处理属性内存管理?
在我的应用程序中,我使用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内存管理? 现在发布这个游戏视图吗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
请在此“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);//默认值为零这是我在回答中告诉你的:)