0

我收到此错误:

2013-01-21 15:09:49.479 obtl[13136:403] An uncaught exception was raised
2013-01-21 15:09:49.484 obtl[13136:403] [<NSApplication 0x10012a600> valueForUndefinedKey:]: this class is not key value coding-compliant for the key managedObjectContext.
2013-01-21 15:09:49.493 obtl[13136:403] (
    0   CoreFoundation                      0x00007fff8c000f56 __exceptionPreprocess + 198
    1   libobjc.A.dylib                     0x00007fff934f4d5e objc_exception_throw + 43
    2   CoreFoundation                      0x00007fff8c08b1b9 -[NSException raise] + 9
    3   Foundation                          0x00007fff8ef65703 -[NSObject(NSKeyValueCoding) valueForUndefinedKey:] + 240
    4   Foundation                          0x00007fff8ee9c38e _NSGetUsingKeyValueGetter + 108
    5   Foundation                          0x00007fff8ee9c315 -[NSObject(NSKeyValueCoding) valueForKey:] + 392
    6   AppKit                              0x00007fff938596ef -[NSApplication(NSScripting) valueForKey:] + 510
    7   Foundation                          0x00007fff8eebbda2 -[NSObject(NSKeyValueCoding) valueForKeyPath:] + 348
    8   AppKit                              0x00007fff936572fa -[NSBinder _valueForKeyPath:ofObject:mode:raisesForNotApplicableKeys:] + 654
    9   AppKit                              0x00007fff93656fe4 -[NSBinder valueForBinding:resolveMarkersToPlaceholders:] + 171
    10  AppKit                              0x00007fff93656c52 -[NSObjectParameterBinder _updateObject:observedController:observedKeyPath:context:] + 1181
    11  AppKit                              0x00007fff93648f8f -[NSObject(NSKeyValueBindingCreation) bind:toObject:withKeyPath:options:] + 591
    12  AppKit                              0x00007fff936422a1 -[NSIBObjectData nibInstantiateWithOwner:topLevelObjects:] + 1079
    13  AppKit                              0x00007fff936388bb loadNib + 322
    14  AppKit                              0x00007fff93637db8 +[NSBundle(NSNibLoading) _loadNibFile:nameTable:withZone:ownerBundle:] + 217
    15  AppKit                              0x00007fff93637cd3 +[NSBundle(NSNibLoading) loadNibFile:externalNameTable:withZone:] + 141
    16  AppKit                              0x00007fff93637c16 +[NSBundle(NSNibLoading) loadNibNamed:owner:] + 364
    17  AppKit                              0x00007fff938a8cd7 NSApplicationMain + 398
    18  obtl                                0x0000000100001b52 main + 34
    19  obtl                                0x0000000100001b24 start + 52
)
2013-01-21 15:09:49.503 obtl[13136:403] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<NSApplication 0x10012a600> valueForUndefinedKey:]: this class is not key value coding-compliant for the key managedObjectContext.'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007fff8c000f56 __exceptionPreprocess + 198
    1   libobjc.A.dylib                     0x00007fff934f4d5e objc_exception_throw + 43
    2   CoreFoundation                      0x00007fff8c08b1b9 -[NSException raise] + 9
    3   Foundation                          0x00007fff8ef65703 -[NSObject(NSKeyValueCoding) valueForUndefinedKey:] + 240
    4   Foundation                          0x00007fff8ee9c38e _NSGetUsingKeyValueGetter + 108
    5   Foundation                          0x00007fff8ee9c315 -[NSObject(NSKeyValueCoding) valueForKey:] + 392
    6   AppKit                              0x00007fff938596ef -[NSApplication(NSScripting) valueForKey:] + 510
    7   Foundation                          0x00007fff8eebbda2 -[NSObject(NSKeyValueCoding) valueForKeyPath:] + 348
    8   AppKit                              0x00007fff936572fa -[NSBinder _valueForKeyPath:ofObject:mode:raisesForNotApplicableKeys:] + 654
    9   AppKit                              0x00007fff93656fe4 -[NSBinder valueForBinding:resolveMarkersToPlaceholders:] + 171
    10  AppKit                              0x00007fff93656c52 -[NSObjectParameterBinder _updateObject:observedController:observedKeyPath:context:] + 1181
    11  AppKit                              0x00007fff93648f8f -[NSObject(NSKeyValueBindingCreation) bind:toObject:withKeyPath:options:] + 591
    12  AppKit                              0x00007fff936422a1 -[NSIBObjectData nibInstantiateWithOwner:topLevelObjects:] + 1079
    13  AppKit                              0x00007fff936388bb loadNib + 322
    14  AppKit                              0x00007fff93637db8 +[NSBundle(NSNibLoading) _loadNibFile:nameTable:withZone:ownerBundle:] + 217
    15  AppKit                              0x00007fff93637cd3 +[NSBundle(NSNibLoading) loadNibFile:externalNameTable:withZone:] + 141
    16  AppKit                              0x00007fff93637c16 +[NSBundle(NSNibLoading) loadNibNamed:owner:] + 364
    17  AppKit                              0x00007fff938a8cd7 NSApplicationMain + 398
    18  obtl                                0x0000000100001b52 main + 34
    19  obtl                                0x0000000100001b24 start + 52
)
terminate called throwing an exception

相关信息:

Mac OSX App(试图让拥有 Snow Leopard 的用户也能使用它)。一切都适当地绑定到FileOwner.managedObjectContext适当的实体。我已经三次检查了我所有的表格、按钮等,以确保它们连接到正确的绑定。我只有 1 个窗口文件。我在 Mac Lion 上使用 Xcode 4.5.2(不使用自动布局)。我不知道如何解决这个问题——是的,我研究了很多类似的问题,并尝试了一些相同的解决方案,但无济于事。

4

1 回答 1

0

从崩溃日志中,您似乎正在加载一个 nib,并且该 nib 尝试访问managedObjectContext在该 nib 的所有者中定义的属性。它没有找到,所以崩溃了。这可能是由于笔尖所有者错误。

我建议查看您的 nib 文件:

  1. 文件的所有者应该是类型:NSApplication;

  2. 文件的所有者应该有一个delegate绑定到应用程序委托的出口;

  3. 应用程序委托应声明该managedObjectContext属性。

于 2013-01-21T21:26:37.877 回答