Reputation: 75
What I would specifically like to do is test in a view controller X's view will appear method
if ('view controller X' is the first responder) {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(TestSelector2:) name:UIApplicationDidBecomeActiveNotification object:nil];
}
'view controller x' in the above example code is nothing but 'self', I used view controller x for clarity
because currently every view controller I have subscribing to the UIApplicationDidBecomeActiveNotification is getting called and they are each calling theire respective methods. I would only like one view controller to be notified that the application became active at a time, the view controller I would like to be notified should always be the one visible to the user (the first responder). Can someone help, I am new to IOS dev
Thanks
Upvotes: 1
Views: 1185
Reputation: 9536
If you're using a navigation controller you can access it using navigationController.visibleViewController
Upvotes: 1