class not value compliant

Discussion in 'iOS Programming' started by Kapthehat, Aug 28, 2013.

  1. Kapthehat, Aug 28, 2013
    Last edited: Aug 28, 2013

    Kapthehat macrumors member

    Joined:
    Jul 1, 2013
    #1
    Hello,

    I have a datepicker on my XIB labelled "BIDDatePickerViewController" and a class of the same name. Yet when I run the app on the simulator, I get a message stating:-

    "NSUnknownKeyException', reason: '[<BIDDatePickerViewController 0x762a5b0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key datepicker.'

    What am I doing wrong ? thanks

    regards

    Kaps
     
  2. Duncan C macrumors 6502a

    Duncan C

    Joined:
    Jan 21, 2008
    Location:
    Northern Virginia
    #2
    Cocoa has some simple naming conventions that you should follow.

    Never use the same name for both a class and an instance variable/property/local variable.

    Class names should start with an upper case letter, and method names, properties, instance variables, and local variables should start with a lower case letter.

    Using the same names for both classes and instance variables might not be causing your problem, but it is certainly making it harder to figure out.

    There is a refactor command in Xcode that will change a name globally. Use that to clean up your naming.

    The "...this class is not key value coding-compliant for the key..." error usually means that you set up and IBOutlet link in IB, then later renamed the outlet, so IB is trying to set up a link to an instance variable or property that doesn't exist any more. Break the outlet link "datepicker" in IB and then re-link it with the correct instance variable/property. That should fix the error.
     
  3. Kapthehat thread starter macrumors member

    Joined:
    Jul 1, 2013
    #3
    resolved -classes not value compliant.

    thanks - your idea of breaking and rebuilding all the connections worked !!
     
  4. Duncan C macrumors 6502a

    Duncan C

    Joined:
    Jan 21, 2008
    Location:
    Northern Virginia
    #4
    You don't have to break and rebuild them all. Just look for the one with the name that appears in your error message. It will also show the link differently (in red, if memory serves).
     
  5. Kapthehat thread starter macrumors member

    Joined:
    Jul 1, 2013
  6. Tander macrumors 6502a

    Tander

    Joined:
    Oct 21, 2011
    Location:
    Johannesburg, South Africa
    #6
    Just for future reference - edit your original post and change the pre-fix to Resolved. That way anyone reading the main page will know this thread has been resolved without going into it.
     
  7. Duncan C macrumors 6502a

    Duncan C

    Joined:
    Jan 21, 2008
    Location:
    Northern Virginia
    #7

Share This Page