Reputation: 277
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.
Upvotes: 5
Views: 3990
Reputation: 21
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).
Upvotes: 2
Reputation: 277
I solved the problem, but if you're having the same issue I would recommend trying any of the above methods first because mine is time consuming. I moved EditViewController.h/.m/.xib to my desktop and created new EditViewController.h/.m/.xib. I then rebuilt the xib by hand and copy/pasted the code from the original into the new one. Thankfully my xib wasn't too complicated.
Upvotes: 0
Reputation: 52778
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}/*
Upvotes: 7