2009-07-06 06:49:13.666 Spark[9825:10b] -[<NSUserDefaultsController 0x137af0> valueForUndefinedKey:]: this class is not key value coding-compliant for the key hotKeyDisplayEntry.
爲什麼Xcode中的這些錯誤意味着什麼?
2009-07-06 06:49:13.667 Spark[9825:10b] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<NSUserDefaultsController 0x137af0> valueForUndefinedKey:]: this class is not key value coding-compliant for the key hotKeyDisplayEntry.'
編輯: 什麼,我認爲造成這個問題。
OSStatus MyHotKeyHandler(EventHandlerCallRef nextHandler,EventRef theEvent,void *userData)
{
EventHotKeyID hkCom;
GetEventParameter(theEvent,kEventParamDirectObject,typeEventHotKeyID,NULL,sizeof(hkCom),NULL,&hkCom);
HotKeyController *controller = (HotKeyController *)userData;
int l = hkCom.id;
switch (l) {
case 1: [controller->window makeKeyAndOrderFront:NSApp];
break;
case 2: [controller->searchWindow makeKeyAndOrderFront:nil];
break;
case 3: [controller->entryWindow makeKeyAndOrderFront:nil];
break;
}
return noErr;
}
- (void)awakeFromNib
{
//Register the Hotkeys
EventHotKeyRef gMyHotKeyRef;
EventHotKeyID gMyHotKeyID;
EventTypeSpec eventType;
eventType.eventClass=kEventClassKeyboard;
eventType.eventKind=kEventHotKeyPressed;
InstallApplicationEventHandler(&MyHotKeyHandler,1,&eventType,(void *)self,NULL);
gMyHotKeyID.signature='htk1';
gMyHotKeyID.id=1;
if([[NSUserDefaults standardUserDefaults] integerForKey:@"hotkeyCodeMain"]!=-999) {
RegisterEventHotKey([[NSUserDefaults standardUserDefaults] integerForKey:@"hotkeyCodeMain"], [[NSUserDefaults standardUserDefaults] integerForKey:@"hotkeyModifiersMain"], gMyHotKeyID, GetApplicationEventTarget(), 0, &gMyHotKeyRef);
}
gMyHotKeyID.signature='htk2';
gMyHotKeyID.id=2;
if([[NSUserDefaults standardUserDefaults] integerForKey:@"hotkeyCodeSearch"]!=-999) {
RegisterEventHotKey([[NSUserDefaults standardUserDefaults] integerForKey:@"hotkeyCodeSearch"], [[NSUserDefaults standardUserDefaults] integerForKey:@"hotkeyModifiersSearch"], gMyHotKeyID, GetApplicationEventTarget(), 0, &gMyHotKeyRef);
}
gMyHotKeyID.signature='htk3';
gMyHotKeyID.id=3;
if([[NSUserDefaults standardUserDefaults] integerForKey:@"hotkeyCodeEntry"]!=-999) {
RegisterEventHotKey([[NSUserDefaults standardUserDefaults] integerForKey:@"hotkeyCodeEntry"], [[NSUserDefaults standardUserDefaults] integerForKey:@"hotkeyModifiersEntry"], gMyHotKeyID, GetApplicationEventTarget(), 0, &gMyHotKeyRef);
}
}
在NIB中,我還將文本字段連接到NSDefaultsController。
它可能會幫助張貼圍繞異常的代碼(在調試器中查看回溯會有所幫助) – cobbal 2009-07-06 05:57:18
這不僅僅是您最後一次嘗試此功能時的問題http://stackoverflow.com/questions/ 1072822/why-is-xcode-giving-me-these-errors? – Abizern 2009-07-06 07:04:45
不,它是一組不同的代碼。 – Joshua 2009-07-06 07:09:13