繁体   English   中英

接口生成器文件中的Xcode 6未知类

[英]Xcode 6 Unknown class in Interface Builder file

当按钮链接到视图控制器时,将出现错误。 我很想解决这个问题。 我对Xcode也很陌生。

我已经尝试过,但是没有一个起作用:

  • Interface Builder文件Xcode错误中的未知类
  • Xcode 6奇怪的错误:Interference Builder文件中的未知类
  • 接口构建器文件中的XCode未知类*****

错误是:

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) 

1. Unknown class in Interface Builder file Xcode error表示StoryBoard中的ViewController之一与unknown Class链接在一起。 只是仔细检查。

2.读取错误报告后, reason: '[<UIViewController 0x7aecbd00> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key 但是由于缺乏特定的代码,我只能向您推荐一些“解决方案”。

我将编写一个storeData函数作为示例。 而且objectA是您的DataObject类的实例变量。

func storeData() { 
let defaults = NSUserDefaults.standardUserDefaults()
var data = NSKeyedArchiver.archivedDataWithRootObject(objectA) 
defaults.setValue(data, forUndefinedKey: "DataBase") // The error occur in there
} 
  • 看到该data ,这是对objectA的压缩。 而且objectA继承自Class中提到的Class ,该Classthis class is not key value coding-compliant for the key
  • forUndefinedKey是一种标记或名称,可以使编译器找到正确的数据。

  • 解决方案 :我猜该错误是在数据的I / O过程中发生的。 因此,请检查每个I / O函数并进行阻止,以验证该参数data的未压缩是否继承自同一Class。

PS :如果要使用NSUserDefaults存储数据,则应该了解NSKeyedArchiverNSKeyedUnarchiver ,它们喜欢Zip来压缩数据。 编译器将在存储数据的过程中Archive您的数据,并在读取数据的过程中Unarchive的数据。

原因是当您在.h / .m中更改了IBOutlet属性的名称时,该属性已经连接到笔尖中的File Owner。

从您的笔尖:

在IB中选择对象,然后转到“连接检查器”。 在“参考插座”下,确保您的对象仍未连接到旧的属性名称...如果是,请单击小的“ x”以删除参考并重新构建。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM