"It is assumed that the root controller will be installed in the application windows at the end of the application launch," when the root mode is set

I have the following code in the App Delegate file of the application:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { MBFeedViewController *feedViewController = [[MBFeedViewController alloc] init]; self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; [self.window setRootViewController:feedViewController]; [self.window makeKeyAndVisible]; return YES; } 

Then, when I launch my application, the console displays a message:

In application windows, it is expected that the root controller will be installed at the end of the application launch.

It is impossible to understand this. FeedViewController not nil when I set the RootViewController window.

+4
source share
1 answer

It is impossible to understand this. feedViewController is not null when I set the rootviewcontroller in the window.

Make sure that you correctly initialize the view controller. The most commonly used designated initializer is -initWithNibName:bundle: H2CO3 indicates that init is ok too. In any case, make sure that you also initialize the superclass by calling [super initWithNibName:... bundle:...] or just [super init] .

Then make sure feedViewController.view not zero. When you install the window root window controller, the window will set this kind of controller as its own content. A view controller usually creates its view the first time it accesses the view property, so there is no reason why you should ever get nil if creating a view fails.

Finally, try creating an instance of the plain old UIViewController and set it up as the root window view controller. Do you get the same warning? If so, you may have come across a mistake. If not, take a close look at the MBFeedViewController , especially the initializer (s), -loadView , -viewDidLoad and other methods that are called early in the life of the view controller.

+3
source

All Articles