Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

danielpunt

macrumors newbie
Original poster
Oct 11, 2007
17
0
Netherlands
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. :)
 

MontyClift

macrumors newbie
Sep 2, 2008
18
0
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
 

sabernar

macrumors newbie
Dec 12, 2007
3
0
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

macrumors newbie
Dec 12, 2007
3
0
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.
 

xilus

macrumors newbie
Mar 5, 2009
9
0
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
code01.png

AND ALSO.. the nib name here
code02.png
 

jagatnibas

macrumors regular
Jul 28, 2008
126
0
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

macrumors regular
Jul 28, 2008
126
0
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
 

Attachments

  • ContactsImporter.zip
    31.4 KB · Views: 426

eddietr

macrumors 6502a
Oct 29, 2006
807
0
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.
 

jagatnibas

macrumors regular
Jul 28, 2008
126
0
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

macrumors regular
Jul 28, 2008
126
0
got it

- (UIViewController *) initWithContacts: (NSArray *)importedConatcts {
MainViewController *viewController = [[MainViewController alloc] initWithNibName:mad:"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
 

guetux

macrumors newbie
Aug 11, 2010
1
0
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
 

Vlade

macrumors 6502a
Feb 2, 2003
966
4
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!
 

symmetric

macrumors newbie
Nov 5, 2011
2
0
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.
 

rgeade

macrumors newbie
Sep 30, 2009
3
0
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!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.