9
votes
 UIStoryboard*  sb = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
    UIViewController* vc = [sb instantiateViewControllerWithIdentifier:@"SettingsViewController"];
    [[self navigationController] pushViewController:vc animated:YES];

Trying to push a viewcontroller from my NavigationController in Storyboard and I keep getting this error.

* Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<SettingsViewController 0x1f98f100> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key keyPath.' * First throw call stack: (0x31f4a3e7 0x39c3b963 0x31f4a0d5 0x327b87d9 0x327b4543 0x31ed08a5 0x33ef5e69 0x340e5b09 0x71aa3 0x33e1b31d 0x33e9dda9 0x32859657 0x31f1f857 0x31f1f503 0x31f1e177 0x31e9123d 0x31e910c9 0x35a6f33b 0x33dad2b9 0x6567d 0x3a068b20) libc++abi.dylib: terminate called throwing an exception

4

4 Answers

44
votes

I got this error becouse I had put something in the "User Defined Runtime Attributes" field in the "Identity inspector" tab. By mystake I left the default keyPath value for the Key Path column and that caused the problem.

Screenshot from xcode interface builder

4
votes

Most likely, the SettingsViewController defined in the storyboard contains a reference to an IBOutlet called keyPath, but keyPath is not defined in the class.

To remedy, select the view controller in storyboard, select the connections inspector (far right tab on the right pane), and review the connections. There's probably one there called keyPath, and it probably has a "!" near it. Delete that one (and any others with "!").

1
votes

Use this & check:

UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
 SettingsViewController *myVC = (SettingsViewController *)[mainStoryboard instantiateViewControllerWithIdentifier:@"SettingsViewController"];
[self.navigationController pushViewController:myVC animated:YES];
0
votes

Right click xib file, open as source code to find the "keyPath".