Possible kernel error: do attributes with the name "updated" work incorrectly?

I have a Core Data object called Post . One of its attributes is called updated , and it is a date. The saved XML is as follows:

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

From this, I came to the conclusion that the data is stored correctly. When I read the data back, the return value will be NSCFNumber , not NSDate .

However, when I changed the name from updated to pubDate , it worked correctly. updated not declared in the headers for NSManagedObject or NSObject , so I assume this should be a private method.

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

I realized this after several hours of dizziness / decay of anger.

+4
source share
2 answers

NSManagedObject already has the isUpdated property, which is set to YES when the object has changes that have not been committed. This is a valid getter name for the BOOL value, so Core Data does nothing with your updated property. You must rename your property.

+7
source

If you rename your property, this is not an option; you can set the expression to FUNCTION($source, "updated") in the mapping model. This will force the migration to use a method called updated instead of an updated property (for example, [entity updated] instead of entity.updated ).

In general, I agree with the accepted answer, if possible, using a name other than "updated".

+3
source

Source: https://habr.com/ru/post/1286057/


All Articles