gpt4 book ai didi

iphone - 释放 Root View Controller

转载 作者:行者123 更新时间:2023-11-28 20:19:43 24 4
gpt4 key购买 nike

我里面有如下语句

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

语句是:

root_view_controller = [[Root_View_Controller alloc] initWithNibName:@"Base_View" bundle : nil];

我没有使用 ARC,所以我考虑在

中释放 root_view_controller
- (void)applicationWillTerminate:(UIApplication *)application

我的问题是:上面的做法可以吗?并且:在发布 root_view_controller 之前是否应该添加任何其他清理代码?

最佳答案

AppDelegate.m

- (void)dealloc
{
[_window release];
[_viewController release];
[super dealloc];
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
self.viewController = [[[MLViewController alloc] initWithNibName:@"MLViewController" bundle:nil] autorelease];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}

如果你想释放你的 Root_View_Controller,你需要像上面的代码一样在 dealloc 方法中执行它

关于iphone - 释放 Root View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16482643/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com