views:

242

answers:

2

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.

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.'

EDIT: What I think caused the problem.

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);
    }

}

In the NIB I also connected a text field to a NSDefaultsController.

+1  A: 

You (or some code) appears to be using key-value coding on your classes. I assume there's a hotKeyDisplayEntry ivar somewhere, maybe defined in a nib and a connection made but not in your class?

Also read this:

Key-Value Coding in Cocoa (apple.com)

If it isn't the above it is probably either specified an Observer on an ivar or are using object serialization and don't actually have an accessor method for it, and thus throws an exception. Either or, you need to expand a bit on what you are actually doing for me to help you!

Jeffrey Forbes
I was trying to make a Hotkey, I will post the code which I think made the problem for you to have a look at.
Joshua
Updated the first post with more info, what do you think is wrong now?
Joshua
+3  A: 

In general, this means that you are attempting to access a key called hotKeyDisplayEntry for some object, but that object has no such key. You have likely made a typo or minor logical error.

John Feminella
Specifically, Joshua, you're trying to access a hotKeyDisplayEntry property of the User Defaults Controller, but it doesn't have such a property. Did you forget to bind through its values property? (Controller key: values; model key path: hotKeyDisplayEntry)
Peter Hosey
Ah, That's where I went wrong, Thanks Peter!
Joshua