Take the 2-minute tour ×

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.

share|improve this question
add comment

2 Answers

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.

share|improve this answer
add comment

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

share|improve this answer
What kind of naming scheme would you use for a category whose purpose was just to add the business logic of the model into the class? –  RonLugge Aug 22 '12 at 4:11
Here is a naming convention example for categories: cupsofcocoa.com/2011/03/27/objective-c-lesson-8-categories –  Kibitz503 Aug 30 '12 at 19:00
Thanks for the help. –  RonLugge Aug 30 '12 at 23:24
add comment

Your Answer


