我刚开始学习可可编程。我试图构建一个简单的imageviewer。我创建了一个新项目,然后从对象库中添加了一个图像查看器。问题是我得到了一个我甚至无法通过谷歌搜索找到的错误。
2012-04-21 20:36:20.620 ImageViewer[2095:403] An uncaught exception was raised
2012-04-21 20:36:20.621 ImageViewer[2095:403] *** -[NSKeyedUnarchiver decodeObjectForKey:]: cannot decode object of class (IKImageView)
2012-04-21 20:36:20.624 ImageViewer[2095:403] (
0 CoreFoundation 0x00007fff83a42fc6 __exceptionPreprocess + 198
1 libobjc.A.dylib 0x00007fff89dd3d5e objc_exception_throw + 43
2 CoreFoundation 0x00007fff83a42dfa +[NSException raise:format:arguments:] + 106
3 CoreFoundation 0x00007fff83a42d84 +[NSException raise:format:] + 116
4 Foundation 0x00007fff8b957729 _decodeObjectBinary + 2714
5 Foundation 0x00007fff8b95899a -[NSKeyedUnarchiver _decodeArrayOfObjectsForKey:] + 1193
6 Foundation 0x00007fff8b92f480 -[NSArray(NSArray) initWithCoder:] + 486
7 Foundation 0x00007fff8b9577bb _decodeObjectBinary + 2860
8 Foundation 0x00007fff8b956ad6 _decodeObject + 201
9 AppKit 0x00007fff8eceac18 -[NSView initWithCoder:] + 1051
10 Foundation 0x00007fff8b9577bb _decodeObjectBinary + 2860
11 Foundation 0x00007fff8b956ad6 _decodeObject + 201
12 AppKit 0x00007fff8eddc106 -[NSWindowTemplate initWithCoder:] + 3998
13 Foundation 0x00007fff8b9577bb _decodeObjectBinary + 2860
14 Foundation 0x00007fff8b95899a -[NSKeyedUnarchiver _decodeArrayOfObjectsForKey:] + 1193
15 Foundation 0x00007fff8b95839b -[NSSet(NSSet) initWithCoder:] + 519
16 Foundation 0x00007fff8b9577bb _decodeObjectBinary + 2860
17 Foundation 0x00007fff8b956ad6 _decodeObject + 201
18 AppKit 0x00007fff8ebed99d -[NSIBObjectData initWithCoder:] + 2099
19 Foundation 0x00007fff8b9577bb _decodeObjectBinary + 2860
20 Foundation 0x00007fff8b956ad6 _decodeObject + 201
21 AppKit 0x00007fff8ebed048 loadNib + 235
22 AppKit 0x00007fff8ebec59c +[NSBundle(NSNibLoading) _loadNibFile:nameTable:withZone:ownerBundle:] + 217
23 AppKit 0x00007fff8ebec4b7 +[NSBundle(NSNibLoading) loadNibFile:externalNameTable:withZone:] + 141
24 AppKit 0x00007fff8ebec3fa +[NSBundle(NSNibLoading) loadNibNamed:owner:] + 364
25 AppKit 0x00007fff8ee5f9b3 NSApplicationMain + 398
26 ImageViewer 0x00000001087035a2 main + 34
27 ImageViewer 0x0000000108703574 start + 52
28 ??? 0x0000000000000003 0x0 + 3
)
看起来......我需要链接一个框架,但是cocoa框架已经链接了。
还有其他我需要检查的事情吗?
答案 0 :(得分:4)
堆栈跟踪抱怨缺少IKImageView
类,它是ImageKit的一部分,而ImageKit又是Quartz框架的一部分。
您需要将Quartz.framework
添加到项目中。
答案 1 :(得分:1)
- [NSKeyedUnarchiver decodeObjectForKey:]:无法解码类的对象(IKImageView)
您是否已将ImageKit框架添加到项目中?除非您这样做,否则您的应用不会包含定义IKImageView的代码。