Basically, in my FirstViewController, I have an IBAction to push a ViewController using the navigationController.
I also have a NSObject file for several of my methods, and want to perform the same action when one of those methods is called. Since an NSObject doesn't have a navigation controller, I set up the code like this:
I try to run the code, and the NSLog gets called, but the app crashes with this in console for reason:
Why is it trying to pull a navigation controller from the AppDelegate for my code, instead of from FirstViewController?
Code:
- (IBAction)openInbox:(UIButton*)sender {
NSLog(@"Trying to launch displayInboxTable");
UIViewController *inboxVC=[[XLappMgr get ]getInboxViewController];
[self.navigationController pushViewController:inboxVC animated:YES];
}
Code:
NSLog(@"CodeCalled");
UIViewController *inboxVC=[[XLappMgr get ]getInboxViewController];
FirstViewController *appDelegate = (FirstViewController *)[[UIApplication sharedApplication] delegate];
[appDelegate.navigationController pushViewController:inboxVC animated:YES];
Code:
2012-03-10 22:06:47.450 Bell Avenue[341:707] CodeCalled
2012-03-10 22:06:47.451 Bell Avenue[341:707] -[BellAvenueAppDelegate navigationController]: unrecognized selector sent to instance 0x2e6ba0
2012-03-10 22:06:47.453 Bell Avenue[341:707] *** Terminating app due to uncaught exception