NSDatePicker Binding To A Core Data Date Attribute

Discussion in 'Mac Programming' started by DVD Plaza, Jan 12, 2008.

  1. DVD Plaza macrumors member

    Joined:
    Jan 12, 2008
    Location:
    adelaide.sa.au
    #1
    I've bound an NSDatePicker to a date attribute in one of my Core Data entities via an NSArrayController.

    This causes the following errors in the debugger console whenever the value is triggered:

    Code:
    2008-01-13 10:24:42.360 Ziggy[14788:10b] Error setting value for key path selection.lastActivity of object <NSArrayController: 0x139280>[entity: IOControllers, number of selected objects: 1] (from bound object <NSDatePicker: 0x12fd50> with object ID 404 in Nib named MainMenu.nib): [<NSManagedObject 0x1e0460> setValue:forUndefinedKey:]: the entity IOControllers is not key value coding-compliant for the key lastActivity.
    All my other attributes work just fine, it's only the date attribute that's failing but I can't for the life of me work out why. I've even resorted to Apple's own Core Data videos, which cover using a date attribute with an NSDatePicker, but other than all of Apple's documentation still covering Xcode 2.x instead of 3.0 they don't do anything different to what I have.

    I'm using Xcode 3 and Leopard - has something changed that is breaking this?
     
  2. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #2
    Well it seems like the last part of the error describes perfectly the problem:
    Are you sure you bound it to the right object?
     
  3. DVD Plaza thread starter macrumors member

    Joined:
    Jan 12, 2008
    Location:
    adelaide.sa.au
    #3
    You'd think so, I've been bashing my head against the wall telling myself I've done something stupid, yet for the life of me cannot see why that would be a problem... it's an NSDatePicker against a Date attribute, they're compatible! I've even tried going as far as shoving a Date Formatter against it, as redundant as that might be, to no avail. It just doesn't seem possible that key value coding-compliant could be anything to do with it.

    Yet the other aspect of the error, forUndefinedKey, shouldn't be a problem either... I've simply bound the object to my lastActivity entity... what's so hard about that!?! :confused:

    Edit:
    OMG!!! I bound my NSDatePicker to lastActivity, but in my entity I had a typo in my attribute... lastActivty! No wonder I couldn't spot it!!! Nuked my old data file, since this has changed the structure, and it's working a charm!

    Thanks kainjow, you WERE a big help - doubting myself wasn't good enough, you questioning me finally made me spot it!
     
  4. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #4
    Cool, glad you got it working.

    And this is why I'm not a big fan of KVC. It is too easy to mess up and no way for the compiler to check.
     
  5. Eraserhead macrumors G4

    Eraserhead

    Joined:
    Nov 3, 2005
    Location:
    UK
    #5
    What is KVC?
     
  6. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
  7. Eraserhead macrumors G4

    Eraserhead

    Joined:
    Nov 3, 2005
    Location:
    UK
    #7
    Thanks, I hadn't heard the acronym before :eek:.
     

Share This Page