1

第一次编译后,Xcode 从 Thread 1 发出关于 SIGABRT 的错误。错误日志显示了这个,

2012-11-18 20:26:37.866 Test app[26222:8a03] Unknown class 'AppDelegate', using 'NSObject' instead. Encountered in Interface Builder file at path /Users/tommiller/Library/Developer/Xcode/DerivedData/Test_app-gvobsrwxsylgvkamecrxetkkkorf/Build/Products/Debug/Test app.app/Contents/Resources/en.lproj/MainMenu.nib.
2012-11-18 20:26:37.908 Test app[26222:8a03] -[_NSControllerObjectProxy copyWithZone:]: unrecognized selector sent to instance 0x7fcfb8659660
2012-11-18 20:26:37.909 Test app[26222:8a03] An uncaught exception was raised
2012-11-18 20:26:37.909 Test app[26222:8a03] -[_NSControllerObjectProxy copyWithZone:]: unrecognized selector sent to instance 0x7fcfb8659660
2012-11-18 20:26:37.913 Test app[26222:8a03] (
    0   CoreFoundation                      0x000000010e42dfc6 __exceptionPreprocess + 198
    1   libobjc.A.dylib                     0x000000010e29bd5e objc_exception_throw + 43
    2   CoreFoundation                      0x000000010e4ba2ae -[NSObject doesNotRecognizeSelector:] + 190
    3   CoreFoundation                      0x000000010e41ae73 ___forwarding___ + 371
    4   CoreFoundation                      0x000000010e41ac88 _CF_forwarding_prep_0 + 232
    5   AppKit                              0x000000010eef3178 -[NSCell _setContents:] + 73
    6   AppKit                              0x000000010eef3055 -[NSCell setObjectValue:] + 160
    7   AppKit                              0x000000010f115adc -[_NSPlaceholderTextFieldPlugin showValue:inObject:] + 388
    8   AppKit                              0x000000010f0fdf31 -[NSValueBinder _adjustObject:mode:observedController:observedKeyPath:context:editableState:adjustState:] + 809
    9   AppKit                              0x000000010f0fdb74 -[NSValueBinder _observeValueForKeyPath:ofObject:context:] + 303
    10  AppKit                              0x000000010f1158cf -[NSTextValueBinder _observeValueForKeyPath:ofObject:context:] + 43
    11  AppKit                              0x000000010eeec777 -[NSObject(NSKeyValueBindingCreation) bind:toObject:withKeyPath:options:] + 591
    12  AppKit                              0x000000010eee5a89 -[NSIBObjectData nibInstantiateWithOwner:topLevelObjects:] + 1079
    13  AppKit                              0x000000010eedc09f loadNib + 322
    14  AppKit                              0x000000010eedb59c +[NSBundle(NSNibLoading) _loadNibFile:nameTable:withZone:ownerBundle:] + 217
    15  AppKit                              0x000000010eedb4b7 +[NSBundle(NSNibLoading) loadNibFile:externalNameTable:withZone:] + 141
    16  AppKit                              0x000000010eedb3fa +[NSBundle(NSNibLoading) loadNibNamed:owner:] + 364
    17  AppKit                              0x000000010f14e9b3 NSApplicationMain + 398
    18  Test app                            0x000000010e22de12 main + 34
    19  Test app                            0x000000010e22dde4 start + 52
)
2012-11-18 20:26:37.972 Test app[26222:8a03] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[_NSControllerObjectProxy copyWithZone:]: unrecognized selector sent to instance 0x7fcfb8659660'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010e42dfc6 __exceptionPreprocess + 198
    1   libobjc.A.dylib                     0x000000010e29bd5e objc_exception_throw + 43
    2   CoreFoundation                      0x000000010e4ba2ae -[NSObject doesNotRecognizeSelector:] + 190
    3   CoreFoundation                      0x000000010e41ae73 ___forwarding___ + 371
    4   CoreFoundation                      0x000000010e41ac88 _CF_forwarding_prep_0 + 232
    5   AppKit                              0x000000010eef3178 -[NSCell _setContents:] + 73
    6   AppKit                              0x000000010eef3055 -[NSCell setObjectValue:] + 160
    7   AppKit                              0x000000010f115adc -[_NSPlaceholderTextFieldPlugin showValue:inObject:] + 388
    8   AppKit                              0x000000010f0fdf31 -[NSValueBinder _adjustObject:mode:observedController:observedKeyPath:context:editableState:adjustState:] + 809
    9   AppKit                              0x000000010f0fdb74 -[NSValueBinder _observeValueForKeyPath:ofObject:context:] + 303
    10  AppKit                              0x000000010f1158cf -[NSTextValueBinder _observeValueForKeyPath:ofObject:context:] + 43
    11  AppKit                              0x000000010eeec777 -[NSObject(NSKeyValueBindingCreation) bind:toObject:withKeyPath:options:] + 591
    12  AppKit                              0x000000010eee5a89 -[NSIBObjectData nibInstantiateWithOwner:topLevelObjects:] + 1079
    13  AppKit                              0x000000010eedc09f loadNib + 322
    14  AppKit                              0x000000010eedb59c +[NSBundle(NSNibLoading) _loadNibFile:nameTable:withZone:ownerBundle:] + 217
    15  AppKit                              0x000000010eedb4b7 +[NSBundle(NSNibLoading) loadNibFile:externalNameTable:withZone:] + 141
    16  AppKit                              0x000000010eedb3fa +[NSBundle(NSNibLoading) loadNibNamed:owner:] + 364
    17  AppKit                              0x000000010f14e9b3 NSApplicationMain + 398
    18  Test app                            0x000000010e22de12 main + 34
    19  Test app                            0x000000010e22dde4 start + 52
)
terminate called throwing an exception(lldb) 

信号来自main.mreturn NSApplicationMain(argc, (const char **)argv);内部,

#import <Cocoa/Cocoa.h>

int main(int argc, char *argv[])
{
    return NSApplicationMain(argc, (const char **)argv);
}

我很少收到这些记录的错误,所以我不知道错误指向什么。我最好的猜测是14 AppKit 0x000000010eedb59c +[NSBundle(NSNibLoading)_loadNibFile:nameTable:withZone:ownerBundle:] + 217没有加载 XIB?...我该如何解决这个问题?

4

1 回答 1

1

如果您查看最初的错误:

Unknown class 'AppDelegate', using 'NSObject' instead. Encountered in Interface Builder file

它告诉您,在您的代码中的某处,您尝试在假定为 AppDelegate 的对象上调用消息选择器,但事实并非如此。该错误是在加载 MainMenu.nib 时发生的。

所以它可能不是你的代码,而是你的 MainMenu 视图是如何连接到项目中的。你想打开你的 MainMenu XIB 文件并检查它是否连接到应用程序的委托。

于 2012-11-19T02:06:45.107 回答