Mac Core Data UnCaught Exception

时间:2013-01-21 21:15:14

标签: macos cocoa core-data

我收到此错误:

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(不使用自动布局)。我迷失了如何解决这个问题 - 是的,我已经研究了很多类似的问题,并尝试了一些相同的解决方案无济于事。

1 个答案:

答案 0 :(得分:0)

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

我建议您查看您的nib文件:

  1. 文件的所有者应为:NSApplication;

  2. 文件的所有者应该有一个绑定到应用代表的delegate出口;

  3. app委托应声明managedObjectContext属性。