Reputation: 3872
So I have a view that I have put together in another .xib file. It also has it's own .h/.m files.
I am trying to allocate an instance of it in my mainViewController and I keep getting:
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<XXX 0x1c556390> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key XXX
I am using the following code
NSArray* nibViews = [[NSBundle mainBundle] loadNibNamed:@"SubviewClass"
owner:self
options:nil];
self.subview = (SubviewClass *)[nibViews objectAtIndex:0];
self.subview.frame = CGRectMake(82, 182, 155, 96);
[self.view addSubview:self.subview];
However it keeps crashing on the first line.
Upvotes: 1
Views: 193
Reputation: 6652
In your nib you have a view or control that is mapped to a property which does not exist on the owner of the nib which in your code is whatever object calls
NSArray* nibViews = [[NSBundle mainBundle] loadNibNamed:@"SubviewClass"
owner:self
options:nil];
Upvotes: 1
Reputation: 73936
Your SubviewClass
nib has an object that is hooked up to an outlet that doesn't exist. Check the connections for each object in your nib and check that the owner is correct and has the outlets that you are connecting to.
Upvotes: 2
Reputation: 69027
I suspect that you nib file has some problem. Check all the connections from your controller object...
Upvotes: 0