views:

84

answers:

1

I have a Core Data entity called Post. One of it's attributes is called updated and it is a date. The stored XML looks like this:

<attribute name="updated" type="date">266164481.00000000000000000000</attribute>

From this I concluded that the data is being stored correctly. When I read the data back the returned value is a NSCFNumber, not an NSDate.

However, when I changed the name from updated to pubDate it worked properly. updated isn't declared in the headers for NSManagedObject or NSObject, so I guess it must be a private method.

Has anyone else experienced this? Should I report it to Apple?

I figured this out after a few hours of head scratching/foul mouth anger.

+4  A: 

NSManagedObject already has a property called isUpdated, which is set to YES when the object has changes that haven't been committed yet. This is a valid name for a getter for a BOOL value, so Core Data isn't doing anything with your updated property. You should rename your property.

Alex
see here for list of names you should avoid in core data : http://developer.apple.com/documentation/Cocoa/Conceptual/CoreData/Articles/cdManagedObjects.html#//apple_ref/doc/uid/TP40003397-235678
ctshryock
I didn't realize that Cocoa checked for methods with 'is' prefixes.I though it just checked for methods named the same as the key and 'set' + key.
Benedict Cohen