I'm a little confused by whether Core Data generates primitive accessors for NSManagedObject subclasses in the form setPrimitiveAttributeName:, as compared to the form setPrimitiveValue: forKey:, which it seems to do consistently.
The source of my confusion is that I have used the modeling tool (XCode 4) to generate NSManagedSubclasses for two of my entities, which, as far as I can tell, share the same metadata settings, yet one subclass recognizes the setPrimitiveAttributeName form, whereas the other doesn't (it gives me a "method not found" compiler warning).
So, what is the expectation? If I open up a new project, create one entity with one attribute, and use the modeling tool to generate the necessary NSManagedObject subclass code, should I expect it to auto-generate the more efficient form of the primitive accessor or not?
I've been running into a similar problem. While the runtime generates the primitive accessors, Xcode 4 does not generate the declared properties for primitives, you have to do this yourself in the subclass, per the docs.
I personally create a category for every Entity and always put my custom code in there, that way I can regenerate the MOs whenever I want and not have to copy and paste.
You can do this in a category, the interface has this:
@property (nonatomic, retain) NSDate * primitiveLastUsed;
And the implementation has this:
@dynamic primitiveLastUsed;
Pretty slick, makes regenerating MOs from Xcode painless.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With