I'm trying to subscribe myViewController to a custom NSNotification. The view heirarchy looks like this:
window
- rootViewController.view
- scrollView
- myViewController.view
The notification is being sent to the [NSNotificationCenter defaultCenter] from a button inside the rootViewController's view. The rootViewController listens for the notification and responds to it just fine.
I have the same exact "listening" code inside myViewController, but it's not receiving the notification for some reason. If it's part of the app it should receive the notification, correct? I have a debug message inside myViewController's initWithNibName method, so I know that it's subscribing to the notification. I even tried having myViewController listen for ALL notifications by setting the notification name to nil. For example:
NSLog(@"main view controller initialized");
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(statusBarVisibilityChanged:) name:nil object:nil];
But no luck there either. Has anyone seen anything like this happen before with NSNotifications?
Any ideas?
Thanks!
I guess the view controller is deallocated. It's a common mistake not to retain a view controller when creating it programmatically.