本文介绍了在AppDelegate中,主UIWindow是如何实例化的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Master-Detail Xcode项目中默认代码的片段
A snippet of the default code in a Master-Detail Xcode project
AppDelegate.m
AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
UINavigationController *navigationController = (UINavigationController *)self.window.rootViewController; // *** here ***
MasterViewController *controller = (MasterViewController *)navigationController.topViewController;
controller.managedObjectContext = self.managedObjectContext;
return YES;
}
AppDelegate.h
AppDelegate.h
@property (strong, nonatomic) UIWindow *window;
我知道@synthesize只设置了访问器方法,并且没有自动执行初始化。但是, window
如果从未显式初始化,那么 rootViewController 如何?这只是Xcode在幕后启动吗?
I am aware that @synthesize just sets the accessor methods, and no initialization happens automagically. But how does window
have a non-nil rootViewController
if it is never explicitly initialized? Is this just Xcode init'ing behind the scenes?
推荐答案
来自:
这篇关于在AppDelegate中,主UIWindow是如何实例化的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!