我在 App Delegate 中:
- 需要释放我的“window”和“navigationController”吗?和
- 我应该在哪里从 (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/