iphone - 在 App Delegate 中,我需要释放我的 "window"和 "navigationController"吗?

标签 iphone ios memory-management uinavigationcontroller uiapplicationdelegate

我在 App Delegate 中:

  1. 需要释放我的“window”和“navigationController”吗?和
  2. 我应该在哪里从 (a) applicationDidReceiveMemoryWarning 和 (b) dealloc 中释放它?

代码 list

@interface weekendviewerAppDelegate : NSObject <UIApplicationDelegate> {
    UIWindow                        *window;
    UINavigationController          *navigationController;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet UINavigationController *navigationController;

@implementation weekendviewerAppDelegate
@synthesize window;
@synthesize navigationController;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    
    RootViewController *rootViewController = (RootViewController *)[navigationController topViewController];
    rootViewController.managedObjectContext = self.managedObjectContext;
    self.window.rootViewController = self.navigationController;

    // Configure and show the window
    [window addSubview:[navigationController view]];
    [window makeKeyAndVisible];

    return YES;
}


.
.

最佳答案

正如 Bolt 时钟所评论的,您需要在 appDelegate 类中添加一个 dealloc 方法。

- (void)dealloc {

    [navigationController release];
    [window release];
    [super dealloc];
}

关于iphone - 在 App Delegate 中,我需要释放我的 "window"和 "navigationController"吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6172223/

相关文章:

ios - 通过外观代理设置 UIBarButtonItem 的文本颜色

ios - 如何将 Firebase 添加到 Today Extension iOS

iOS:使用 PDF 下载的应用程序,建议使用哪种方法? (ftp,休息, SOAP ,..)

objective-c - 关于autorelease/release和【池释放】

ios - Cocos2d CCSprite 位置释放错误

iphone - 使用 SDWebImage IOS 管理服务器上的图像更改

iphone - 如何以编程方式检查应用程序的捆绑版本?

ios - UIVideoEditorController 在 iPad 上崩溃

ios - 删除等宽约束和调整按钮

list - 将 C++ 创建的对象追加到 python 列表并使其由 python 管理