Core Data reserved property names?

  • I got bit by a funny problem today. I was handed a project with a
    datamodel in which a table had a boolean property named "readOnly".
    Chasing a bug where none of the objects I created has this property set,
    I discovered that doing:

    [object setValue:[NSNumber numberWithBool:YES] forKey:@"readOnly"];

    would actually NOT change the property's value. Apparently, this is a
    side effect of KVC since changing the property name to anything else
    (i.e. "readOnly1") would get the code back working.

    Soo .. my question is: how many of these non-obvious reserved names are
    hidden in Core Data? I say non-obvious because I had to class-dump
    CoreData.framework to find some hidden _setReadOnly method in
    NSManagedObject.  Should I file a bug requesting better documentation
    for this?

    Florent
  • On Nov 5, 2007, at 8:43 AM, Florent Pillet wrote:

    > Soo .. my question is: how many of these non-obvious reserved names
    > are hidden in Core Data? I say non-obvious because I had to class-
    > dump CoreData.framework to find some hidden _setReadOnly method in
    > NSManagedObject.  Should I file a bug requesting better
    > documentation for this?
    >
    "Note that a property name cannot be the same as any no-parameter
    method name of NSObject or NSManagedObject. For example, you cannot
    give a property the name "description". There are hundreds of methods
    on NSObject which may conflict with property names—and this list can
    grow without warning from frameworks or other libraries. You should
    avoid very general words (like "font”, and “color”) and words or
    phrases which overlap with Cocoa paradigms (such as “isEditing” and
    “objectSpecifier”)."

    <http://developer.apple.com/documentation/Cocoa/Reference/CoreDataFramework/
    Classes/NSPropertyDescription_Class/Reference/NSPropertyDescription.html
    >

    mmalc
  • You're right as usual.

    I had searched the documentation for a conflicting readOnly or
    isReadOnly or setReadOnly method but hadn't noticed this bit in the
    NSPropertyDescription documentation. That's good advice.

    Thanks,
    Florent

    mmalc crawford wrote:
    >
    > On Nov 5, 2007, at 8:43 AM, Florent Pillet wrote:
    >
    >> Soo .. my question is: how many of these non-obvious reserved names
    >> are hidden in Core Data? I say non-obvious because I had to class-dump
    >> CoreData.framework to find some hidden _setReadOnly method in
    >> NSManagedObject.  Should I file a bug requesting better documentation
    >> for this?
    >>
    > "Note that a property name cannot be the same as any no-parameter method
    > name of NSObject or NSManagedObject. For example, you cannot give a
    > property the name "description". There are hundreds of methods on
    > NSObject which may conflict with property names—and this list can grow
    > without warning from frameworks or other libraries. You should avoid
    > very general words (like "font”, and “color”) and words or phrases which
    > overlap with Cocoa paradigms (such as “isEditing” and “objectSpecifier”)."
    >
    > <http://developer.apple.com/documentation/Cocoa/Reference/CoreDataFramework/
    Classes/NSPropertyDescription_Class/Reference/NSPropertyDescription.html
    >
    >
    >
    > mmalc
previous month november 2007 next month
MTWTFSS
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30    
Go to today