NSManagedObject subclass properties

I had a subclass of NSObject that acted as my app's main data model, with lots of properties and methods. I decided I wanted to use Core Data to saved this data, so I changed the subclass to be of NSManagedObject. I created the entity in the .xcdatamodeld and linked it with my NSManagedObject subclass. What I'm wondering is if it is okay to keep properties in my subclass that are not saved? For example, this class contains a NSOperationQueue property, but of course I don't want Core Data interacting with this property.

Answers


When you automagically create (or re-create) an NSManagedObject from an Entity you lose anything else you had in that file. It is common for people to use categories to customize the logic for NSManagedObjects. It allows you to add customization to the default NSManagedObject without changing the code in that file!

Nice and clean.

This link may be helpful: http://developer.apple.com/library/ios/#documentation/cocoa/conceptual/objectivec/chapters/occategories.html


Yes, it is perfectly alright to have properties and methods of its own in a NSManagedObject subclass.

Additionally, if you want any of those properties to take advantage of Core Data caching mechanism, you can add them as transient to your entity model.


Need Your Help

Is there a way to pass data (other than through the property bag) between an analyzer and a code fix provider in Roslyn?

c# code-analysis roslyn

with the new RC release, I was excited to see that there now was a property bag to allow raised diagnostics to have additional data, a major use case of which was, in my opinion, to be able to have...

Why FormData post disabled html fields?

javascript jquery ajax form-data disabled-input

I'm using jquery $.ajax(); function to post data of a form,