Why can't I use "description" as an attribute name for a Core Data entity?

core-data, ios

Solution

Because it conflicts with the `-description` method in `NSObject` (recall that Core Data dynamically generates property accessors and mutators — a property named ‘description’ would require creating an accessor method called `-description`). This is documented in the Core Data Programming Guide and the NSPropertyDescription Class Reference:

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”).

Problem

I have a simple Core Data entity that had a string attribute named "description". The program crashes when it hits: ``` valueForKey:@"description" ``` I changed the "description" attribute to "text" and problem solved. Why does this happen? Is "description" a reserved key word in Core Data? Is it related to calling the description method from NSObject? Is there a reference to these reserved key words if they exist?

Original source