【发布时间】:2011-09-04 13:25:45
【问题描述】:
在 App Delegate 中我:
- 需要释放我的“window”和“navigationController”吗?和
- 我应该从 (a) applicationDidReceiveMemoryWarning 和 (b) dealloc 中释放它?
代码清单
@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;
}
.
.
【问题讨论】:
-
如果您从基于导航的应用程序模板开始,您会看到它们确实在 dealloc 中发布。
标签: iphone ios memory-management uinavigationcontroller uiapplicationdelegate