Go Back   MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Sep 4, 2008, 08:11 AM   #1
danielpunt
macrumors newbie
 
Join Date: Oct 2007
Location: Netherlands
RootViewController is not key value coding-compliant

I have a RootViewController which loads another view called MainViewController like this:

Code:
MainViewController *viewController = [[MainViewController alloc] initWithNibName:@"MainView" bundle:nil];
self.mainViewController = viewController;
And in the MainViewController I have an IBOutlet to an ActivityIndicatorView that I have connected in my MainView.xib

I can build my app without a warning, but when I run the app it causes this exception :
Code:
'NSUnknownKeyException', reason: '[<RootViewController 0x44e660> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key loadIndicator.'
I'm not shure if it has anything to do with this error, but I have declared a @property and @synthesize for loadIndicator in the MainViewController.

Can somebody please direct me to the right direction? Thanks.
__________________
Cinema Display 20"
MacBook Pro unibody 15"
iPhone 3G white 3,5"
danielpunt is offline   0 Reply With Quote
Old Sep 4, 2008, 10:34 AM   #2
MontyClift
macrumors newbie
 
Join Date: Sep 2008
Have you properly linked the view controller code file up to the xib in interface builder? I came across this error a couple of times when I hadnt done that
MontyClift is offline   0 Reply With Quote
Old Nov 2, 2008, 10:21 AM   #3
sabernar
macrumors newbie
 
Join Date: Dec 2007
Did you figure this out? I'm having the same problem. I have a tabbarcontroller that I'm loading a xib into each tab. If I remove the xib from the tabbarcontroller (in Interface Builder), then the app opens successfully (but without the correct view in the tab). If I add the xib into the tabbarcontroller, it crashes with:

*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x30d8b0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key button.'
sabernar is offline   0 Reply With Quote
Old Nov 2, 2008, 11:10 AM   #4
sabernar
macrumors newbie
 
Join Date: Dec 2007
Problem solved. I had to set the Class Identity to the name of the class that is loaded in. I thought that specifying the nib file was enough, but it looks like you need to also set the class for the tab view.
sabernar is offline   0 Reply With Quote
Old Mar 6, 2009, 12:50 AM   #5
xilus
macrumors newbie
 
Join Date: Mar 2009
Thank you, This thread solved my problem.
In return I am posting images for any others that find this thread on google.
(I am sure there will be quite a few)
You must enter the class name here

AND ALSO.. the nib name here
xilus is offline   0 Reply With Quote
Old Mar 10, 2009, 04:14 PM   #6
jagatnibas
macrumors regular
 
Join Date: Jul 2008
where is it ?

hi xilus,

I cant see this window. How did you find these 2 windows ? selected the control and then tools -> ???

is this a problem in 2.1, i am yet to download 2.2.1 sdk

regards
Jagat
jagatnibas is offline   0 Reply With Quote
Old Mar 10, 2009, 04:57 PM   #7
dejo
Moderator
 
dejo's Avatar
 
Join Date: Sep 2004
Location: The Centennial State
Quote:
Originally Posted by jagatnibas View Post
How did you find these 2 windows ? selected the control and then tools -> ???
Tools > Inspector. The first screenshot is from the Identity Inspector (⌘4) and the second one is from the Attributes Inspector (⌘1).
dejo is offline   0 Reply With Quote
Old Mar 22, 2009, 12:22 PM   #8
jagatnibas
macrumors regular
 
Join Date: Jul 2008
scratching my head -- gone mad

Hi All,

I am still unable to find it.

I could see 3 things in nib file File's Owner, First Responder, View

dejo, I assume you had File's owner selected when u clicked tool->inspector

I used all the things like identity inspecotr and inspector i cannot find nibfile window [first figure]

I have attached this code, please help me. As long as the tableview is not mapped to MainViewController iboutlet var, it is fine, the moment it is connected, it gives key value pair error

please help
Attached Files
File Type: zip ContactsImporter.zip (31.4 KB, 261 views)
jagatnibas is offline   0 Reply With Quote
Old Mar 22, 2009, 03:15 PM   #9
dejo
Moderator
 
dejo's Avatar
 
Join Date: Sep 2004
Location: The Centennial State
Quote:
Originally Posted by jagatnibas View Post
dejo, I assume you had File's owner selected when u clicked tool->inspector
I didn't. I hadn't tried it. I was just explaining how to bring up the Identity Inspector and Attributes Inspector.
__________________
dejo is offline   0 Reply With Quote
Old Mar 22, 2009, 05:04 PM   #10
eddietr
macrumors 6502a
 
Join Date: Oct 2006
Location: Virginia
Code:
- (UIViewController *) initWithContacts: (NSArray *)importedConatcts {
	UIViewController *viewController = [[UIViewController alloc] initWithNibName:@"MainViewController" bundle:nil];
	self.contacts = importedConatcts;
	return viewController;
}
So this is the issue right here.

This is the initializer in MainViewController. So in this initialization, you should be setting up the MainViewController instance (which has already been alloc'ed) and then returning it.

Instead, what you are doing is allocating another controller of type UIViewController, and then initializing *that* and returning *that* controller instead of your instance of MainViewController.

And of course the UIViewController instance does not have a property called _contactsTableView, and so when initWithNibName loads your nib, it cannot set the _contactsTableView since that property and setter do not exist for a UIViewController. Therefore, you end up with the "this thing won't respond to my message to set this key/value" error.

Hope that helps.
eddietr is offline   0 Reply With Quote
Old Mar 23, 2009, 04:40 AM   #11
jagatnibas
macrumors regular
 
Join Date: Jul 2008
Thanks

Thanks Eddie,

I kept on wondering around interface builder and forgot to review my own code, so stupid of me. How could I do this !


After this is solved, I foumd out another strange problem. I have contacts NSArray* member variable. and in initwithcontacts i am assigning contacts = importedcontacts. here when i debug i see correct items.

but when this contact is accessed in table callbacks it says nil and 0 number of items. I have tried a lot of things like using self.contacts, doing self.contacts = [[NSArray alloc] initwitharray:importedcontacts]

no avail.

Any solution that comes to your mind ?

I have been on and off from MAC and thats why keep forgetting things, sorry for being silly

regards
Jagat
jagatnibas is offline   0 Reply With Quote
Old Mar 23, 2009, 07:20 AM   #12
jagatnibas
macrumors regular
 
Join Date: Jul 2008
got it

- (UIViewController *) initWithContacts: (NSArray *)importedConatcts {
MainViewController *viewController = [[MainViewController alloc] initWithNibName:@"MainViewController" bundle:nil];
viewController.contacts = importedConatcts;
return viewController;
}

i did this and it solved the problem. but i dont understand whats the difference between self.contacts and viewController.contacts

regards
Jagat
jagatnibas is offline   0 Reply With Quote
Old Aug 11, 2010, 07:18 AM   #13
guetux
macrumors newbie
 
Join Date: Aug 2010
Huge Thank You

Thank you guys sooooo much! Just found this thread by google and it helped me with a problem i've been fighting for days now!!! Keep on rocking
guetux is offline   0 Reply With Quote
Old Apr 21, 2011, 04:36 PM   #14
Vlade
macrumors 6502a
 
Vlade's Avatar
 
Join Date: Feb 2003
Location: Meadville, PA
This was the first thread I found while searching for a solution to the problem, so here is some info that may help someone else. More likely than not it's the other solution listed, but in case anyone is doing something similar to me here is what I found.

To share a view controller with the Mac and iOS versions of one of my projects I did stuff like this

Code:
#if TARGET_OS_IPHONE
typedef UIWindow NSUIWindow;
#else
typedef NSWindow NSUIWindow;
#endif
then
Code:
IBOutlet NSUIWindow *mainWindow;
Interface Builder doesn't follow the typedefs correctly and even though it compiled it failed to launch. IB Does however follow this correctly

Code:
#define NSUIWindow UIWindow
Funny thing is I ran into this problem with two projects a year apart, and forgot the solution in between. Not sure why it worked in the first place, but it's frustrating when a project just crashes after not touching it for 6 months! Now all my game UI are in a custom OpenGL class I wrote, much easier!
Vlade is offline   0 Reply With Quote
Old Nov 5, 2011, 05:12 PM   #15
symmetric
macrumors newbie
 
Join Date: Nov 2011
Sigh, sometimes I hate Xcode's error messages!

I just wasted several hours with this problem. The cause was a little different so I thought I'd post it. Although it turned out to be simple (and in hind sight seems obvious), it was a bear to find!:

I had a bunch of IBOutlets defined for my UITableViewController subclass. Through the course of development, some of them weren't being used anymore, but they were still connected to unused fields in the table view. When these unused properties were commented out it caused this error because the storyboard/view controller was still looking for properties that didn't exist any more.

The solution, of course, was just to remove the unused connections/fields from the storyboard.
symmetric is offline   0 Reply With Quote
Old Dec 17, 2011, 10:52 PM   #16
rgeade
macrumors newbie
 
Join Date: Sep 2009
Quote:
Originally Posted by symmetric View Post
I just wasted several hours with this problem. The cause was a little different so I thought I'd post it. Although it turned out to be simple (and in hind sight seems obvious), it was a bear to find!:

I had a bunch of IBOutlets defined for my UITableViewController subclass. Through the course of development, some of them weren't being used anymore, but they were still connected to unused fields in the table view. When these unused properties were commented out it caused this error because the storyboard/view controller was still looking for properties that didn't exist any more.

The solution, of course, was just to remove the unused connections/fields from the storyboard.
This is exactly what my problem was. I had tested my app on several devices and on the sim and had no issues and submitted to the app store. After it posted, a relative showed me that it crashed at launch on his iPad 1 on iOS 3.2.1. Sure enough, it was because of old, unused connections in IB. It's weird that this didn't cause a problem on newer devices/OS levels. I am not exactly sure if it was the OS level, or the iPad 1 hardware, but it's fixed now!
rgeade is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Sandbox Compliant? Nielsenius App Store Business, Legal and Marketıng 3 May 2, 2014 05:29 PM
class not value compliant Kapthehat iPhone/iPad Programming 6 Sep 4, 2013 09:00 AM
Need to send HIPAA compliant video, how? chrissyhume Digital Video 4 Jan 30, 2013 03:40 AM
Apparently my monitor is not HDCP compliant... but it is gibbo132 Mac Peripherals 6 Oct 21, 2012 01:54 PM
Office 2011 ML compliant? PaulKemp Mac Applications and Mac App Store 4 Jul 26, 2012 12:10 PM

Forum Jump

All times are GMT -5. The time now is 08:09 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps