When i return from child ViewController to parent ViewController. There is an error.
2014-11-20 09:00:48.229 Heritage[64395:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[XYZContinentTableViewController topViewController]: unrecognized selector sent to instance 0x8c60050'
The error shows up when i have 3 level of ViewController, and specifically, from second level ViewController to root ViewController.
I found out the root cause. It is because the unwind segue
- (IBAction)unwindToRegion:(UIStoryboardSegue *)segue
{ }
is mixed up with prepareForSegue.
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
....
}
....
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"UserShowSegueCountry"])
{
UINavigationController *nav = segue.destinationViewController;
XYZCountryTableViewController *vcToPushTo = (XYZCountryTableViewController *)nav.topViewController;
}
}
In this blog post, you have discussed the common causes of this exception, such as passing invalid arguments to methods or accessing null objects. They also provide insights into debugging techniques and offer suggestions for handling and preventing such exceptions in your iOS app. It's a valuable resource for iOS developers facing NSInvalidArgumentException and seeking solutions to resolve or prevent it in their code. Thanks for sharing this great article, You can also contact us here if you are looking forward to Hire Best Android App Developers from India, and we will be happy to help you.
ReplyDelete