Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIViewController is not key value coding-compliant for the key XXXXX. No wrong connections in IB

Tags:

xcode

ios

I get runtime error when displaying EditViewController from my main view controller:

'[<EditViewController 0x7fbef90> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key saveChanges.'

I've done all the different Google/Stack Overflow searches I can think of and all of my results refer to either a Tab Bar or a bad connection in Interface Builder. My project has no tab bar and I removed every connection (except that from the File's Owner, EditViewController, to the view) from every object in my nib. EditViewController does, in fact have a method named -(IBAction)saveChanges.

It's driving me crazy, and I can't figure out what on earth I'm supposed to do. Thanks in advance.

like image 819
WFT Avatar asked Oct 16 '11 03:10

WFT


2 Answers

You may not have any invalid connections from the top view to an IBOutlet but check the File's Owner and First Responder for possible IBAction's that have a connection to a method that is commented out or doesnt exist.

Another idea is to manually disconnect and reconnect each connection. I have experienced issues where I change an IBAction method from - (IBAction)doStuff to - (IBAction)doStuff:(id)sender after connecting in the IB but the connection still says doStuff when it should say doStuff:. That colon doesnt look like much (and its hard as hell to distinguish in the IB) but it changes the action to @selector(doStuff) which is targeting a method that doesnt exist.

Reconnecting couldn't hurt and has become my first troubleshooting step for most xib issues.


Another sure way to find it is grep (from Terminal):

[ 22:20 jon@host ~ ]$ grep -RH "saveChanges" /path/to/${PROJECT_DIR}/*

File's Owner Connections

First Responder Connections

like image 193
chown Avatar answered Sep 21 '22 12:09

chown


I found this issue when trying to add connection to a nib that was for a UITableViewCell.
The File's Owner was set to a custom UITableViewCell class. But rather than that, do as usual: draging from the views directly into the .h file you must set the class of the UITableViewCell object. Then, connect things to that object; not the File's Owner (even though they are the same custom class underneath).

like image 32
Pete Avatar answered Sep 20 '22 12:09

Pete