Reputation: 1525
In my AppDelegate, I'm instantiating a UINavigationController and adding my "main" view (let's call it MainViewController) as the root view controller for the navigation controller. The navigation controller is then added as a subview to the app delegate's window and the window is made visible. I.e.,
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// viewController is a property of the app delegate
viewController = [[MainViewController alloc] init];
viewController.context = [self managedObjectContext];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:viewController];
[self.window addSubview:navController.view];
[self.window makeKeyAndVisible];
return YES;
}
MainViewController adds observers for some NSNotifications that are posted by a subview of a view controller programmatically instantiated and added as a subview of MainViewController. So,
Once I added the UINavigationController to the mix, MainViewController no longer properly handles the notification posted by SubView. If I remove the UINavigationController and simply add MainViewController as a subview of the AppDelegate's window, the notifications are handled properly.
I tried adding an observer to the AppDelegate for one of the notifications posted by SubView and it handles it properly, and while handling that notification, the MainViewController is not nil.
Any guidance would be greatly appreciated. Please let me know if you'd like any clarification.
Upvotes: 0
Views: 324
Reputation: 1525
Ok, a couple of things were happening here:
viewController
was not actually a property on my app delegate. Making it a property caused the NSNotification to be handled again.Upvotes: 0