1
votes

The error comes when the button links to a view controller. I am desperate to fix this problem. I am also quite new to Xcode.

I have tried, but none of them worked:

  • Unknown class in Interface Builder file Xcode error
  • Xcode 6 Strange Bug: Unknown class in Interference Builder file
  • XCode Unknown class ***** in Interface Builder file

The error is:

2015-04-19 15:17:32.565 *****[*******] Unknown class ******* in Interface Builder file.
2015-04-19 15:17:32.671 *****[********] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x7aecbd00> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key ********.'
*** First throw call stack:
(
0   CoreFoundation                      0x01ff7466 __exceptionPreprocess + 182
1   libobjc.A.dylib                     0x01c80a97 objc_exception_throw + 44
2   CoreFoundation                      0x01ff7081 -[NSException raise] + 17
3   Foundation                          0x0190380e -[NSObject(NSKeyValueCoding) setValue:forUndefinedKey:] + 282
4   Foundation                          0x0185f838 _NSSetUsingKeyValueSetter + 115
5   Foundation                          0x0185f7bd -[NSObject(NSKeyValueCoding) setValue:forKey:] + 267
6   Foundation                          0x018950a6 -[NSObject(NSKeyValueCoding) setValue:forKeyPath:] + 386
7   UIKit                               0x0097e329 -[UIRuntimeOutletConnection connect] + 106
8   libobjc.A.dylib                     0x01c96724 -[NSObject performSelector:] + 62
9   CoreFoundation                      0x01f30dbc -[NSArray makeObjectsPerformSelector:] + 316
10  UIKit                               0x0097cdea -[UINib instantiateWithOwner:options:] + 1775
11  UIKit                               0x0079e2a4 -[UIViewController _loadViewFromNibNamed:bundle:] + 270
12  UIKit                               0x0079ea3b -[UIViewController loadView] + 295
13  UIKit                               0x0079ec6f -[UIViewController loadViewIfRequired] + 78
14  UIKit                               0x0079f215 -[UIViewController view] + 35
15  UIKit                               0x00e14ca7 -[_UIFullscreenPresentationController _setPresentedViewController:] + 75
16  UIKit                               0x00774551 -[UIPresentationController initWithPresentedViewController:presentingViewController:] + 113
17  UIKit                               0x007ac6e1 -[UIViewController _presentViewController:withAnimationController:completion:] + 2102
18  UIKit                               0x007af252 __62-[UIViewController presentViewController:animated:completion:]_block_invoke + 345
19  UIKit                               0x007af0a4 -[UIViewController presentViewController:animated:completion:] + 224
20  UIKit                               0x007af56a -[UIViewController presentModalViewController:animated:] + 57
21  UIKit                               0x00c786cd -[UIStoryboardModalSegue perform] + 271
22  UIKit                               0x00c65d89 -[UIStoryboardSegueTemplate _perform:] + 217
23  UIKit                               0x00c65e05 -[UIStoryboardSegueTemplate perform:] + 116
24  libobjc.A.dylib                     0x01c967cd -[NSObject performSelector:withObject:withObject:] + 84
25  UIKit                               0x00648340 -[UIApplication sendAction:to:from:forEvent:] + 99
26  UIKit                               0x006482d2 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 64
27  UIKit                               0x0077ca56 -[UIControl sendAction:to:forEvent:] + 69
28  UIKit                               0x0077ce73 -[UIControl _sendActionsForEvents:withEvent:] + 598
29  UIKit                               0x0077c0dd -[UIControl touchesEnded:withEvent:] + 660
30  UIKit                               0x00698ffa -[UIWindow _sendTouchesForEvent:] + 874
31  UIKit                               0x00699ad5 -[UIWindow sendEvent:] + 791
32  UIKit                               0x0065ebb1 -[UIApplication sendEvent:] + 242
33  UIKit                               0x0066ebf6 _UIApplicationHandleEventFromQueueEvent + 21066
34  UIKit                               0x00642bc7 _UIApplicationHandleEventQueue + 2300
35  CoreFoundation                      0x01f1a98f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
36  CoreFoundation                      0x01f1049d __CFRunLoopDoSources0 + 253
37  CoreFoundation                      0x01f0f9f8 __CFRunLoopRun + 952
38  CoreFoundation                      0x01f0f37b CFRunLoopRunSpecific + 443
39  CoreFoundation                      0x01f0f1ab CFRunLoopRunInMode + 123
40  GraphicsServices                    0x039022c1 GSEventRunModal + 192
41  GraphicsServices                    0x039020fe GSEventRun + 104
42  UIKit                               0x006469b6 UIApplicationMain + 1526
43  Goals                               0x0006d0bd main + 141
44  libdyld.dylib                       0x0450bac9 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 
2
Have you verified that view controller linked to the button has correct class in the identity inspector? - Jakub Vano
I followed one of the answers that said to just type the class named, because the class won't come up in the identity inspector - Milan H
Are you sure you have typed it correctly? - Jakub Vano
I am 100% sure, but I think you might be on to something - Milan H
There might be something wrong with the class or something - Milan H

2 Answers

1
votes

It is cause when you change the name of a IBOutlet property in your .h/.m which you've already connected up to File's Owner in the nib.

From your nib:

Select the object in IB and go to the 'Connections Inspector'. Under 'Referencing Outlets' make sure that your object isn't still connected to the old property name... if it is, click the small 'x' to delete the reference and build again.

1
votes

1.Unknown class in Interface Builder file Xcode error means one of your ViewController in the StoryBoard linked with the unknown Class. Just Check it carefully.

2.After reading your error report, reason: '[<UIViewController 0x7aecbd00> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key. But lacking of specific codes, I can just recommend you some 'solutions'.

I will write a storeData function as the example. And objectA is the instance variable of your DataObject Class.

func storeData() { 
let defaults = NSUserDefaults.standardUserDefaults()
var data = NSKeyedArchiver.archivedDataWithRootObject(objectA) 
defaults.setValue(data, forUndefinedKey: "DataBase") // The error occur in there
} 
  • See that data, which is the compression of objectA. And the objectA was inherited from the Class which mentioned in this class is not key value coding-compliant for the key.

  • The forUndefinedKey is kind of mark or name which leads complier to find correct data.

  • Solution: I guess the error was occurred in the process of the I/O for data. So check your each I/O function and block to verify that if the un-compression of that parameter, data, inherited from the same Class.

PS: If you gonna use NSUserDefaults to store your data, you should understand NSKeyedArchiver and NSKeyedUnarchiver which like Zip to compress the data. The complier will Archive your data in the processing of storing data and Unarchive the data in the processing of reading the data.