我有一个绑定到共享用户默认值控制器的NSArrayController实例。 (见下面的截图)关键路径指向NSData的一个实例,当unarchived应该给出一个数组。但是当笔尖开始加载时,它会给出 -
2011-07-10 23:55:23.093 MyApp[18139:507] -[__NSCFConstantString characterAtIndex:]: Range or index out of bounds
2011-07-10 23:55:23.106 MyApp[18139:507] (
0 CoreFoundation 0x00007fff95729986 __exceptionPreprocess + 198
1 libobjc.A.dylib 0x00007fff90d5dd5e objc_exception_throw + 43
2 CoreFoundation 0x00007fff957297ba +[NSException raise:format:arguments:] + 106
3 CoreFoundation 0x00007fff95729744 +[NSException raise:format:] + 116
4 CoreFoundation 0x00007fff956e750e -[__NSCFString characterAtIndex:] + 94
5 Foundation 0x00007fff94c090a7 NSKeyValuePropertyForIsaAndKeyPathInner + 109
6 Foundation 0x00007fff94c08d43 NSKeyValuePropertyForIsaAndKeyPath + 159
7 Foundation 0x00007fff94c08afb -[NSObject(NSKeyValueObserverRegistration) addObserver:forKeyPath:options:context:] + 82
8 Foundation 0x00007fff94c3f5a0 -[NSKeyValueNestedProperty object:didAddObservance:recurse:] + 222
9 Foundation 0x00007fff94c0a177 -[NSObject(NSKeyValueObserverRegistration) _addObserver:forProperty:options:context:] + 481
10 Foundation 0x00007fff94c08b18 -[NSObject(NSKeyValueObserverRegistration) addObserver:forKeyPath:options:context:] + 111
11 AppKit 0x00007fff95beddd1 -[NSAutounbinder addObserver:forKeyPath:options:context:] + 210
12 AppKit 0x00007fff95a1e323 -[NSBinder _updateObservingRegistration:] + 859
13 AppKit 0x00007fff95a1d4a1 -[NSBinder establishConnection] + 314
14 AppKit 0x00007fff95a1185b -[NSObject(NSKeyValueBindingCreation) bind:toObject:withKeyPath:options:] + 591
15 AppKit 0x00007fff95a0ab81 -[NSIBObjectData nibInstantiateWithOwner:topLevelObjects:] + 1079
16 AppKit 0x00007fff95a011b9 loadNib + 322
17 AppKit 0x00007fff95a006b6 +[NSBundle(NSNibLoading) _loadNibFile:nameTable:withZone:ownerBundle:] + 217
18 AppKit 0x00007fff95a005d1 +[NSBundle(NSNibLoading) loadNibFile:externalNameTable:withZone:] + 141
19 AppKit 0x00007fff95bee328 -[NSWindowController loadWindow] + 221
20 AppKit 0x00007fff95bee0e3 -[NSWindowController window] + 75
21 AppKit 0x00007fff95bedf51 -[NSWindowController showWindow:] + 40
22 MyApp 0x00000001000024af -[MyAppDelegate showPreferencesWindow:] + 255
23 MyApp 0x0000000100005229 -[TBStatusWindowController preferences:] + 89
24 CoreFoundation 0x00007fff9571911d -[NSObject performSelector:withObject:] + 61
25 AppKit 0x00007fff95afd852 -[NSApplication sendAction:to:from:] + 139
26 AppKit 0x00007fff95afd784 -[NSControl sendAction:to:] + 88
27 AppKit 0x00007fff95afd6af -[NSCell _sendActionFrom:] + 137
28 AppKit 0x00007fff95afcb7a -[NSCell trackMouse:inRect:ofView:untilMouseUp:] + 2014
29 AppKit 0x00007fff95b7c57c -[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 489
30 AppKit 0x00007fff95afb786 -[NSControl mouseDown:] + 786
31 AppKit 0x00007fff95ac666e -[NSWindow sendEvent:] + 6280
32 AppKit 0x00007fff95a5ef19 -[NSApplication sendEvent:] + 5665
33 AppKit 0x00007fff959f542b -[NSApplication run] + 548
34 AppKit 0x00007fff95c7352a NSApplicationMain + 867
35 MyApp 0x0000000100001a40 main + 32
36 MyApp 0x0000000100001a14 start + 52
)
那么我的配置有什么问题?
答案 0 :(得分:1)
为什么空的NSData
对象反序列化为空NSArray
?没有数据,因此unarchiver甚至无法知道您的对象具有哪个类。如果要取消归档空NSArray
,则必须先归档空NSArray
。这不会导致空NSData
。
答案 1 :(得分:0)
问题的原因与此完全无关。事实证明我的配置没有任何问题。
感谢您的时间,omz。