Core Data Subclassing


#1

In the book, the authors created an NSManagedObject subclass for each entity in the core data database and then added methods etc. to these subclasses. The Stanford lectures indicate that this may not be such a good idea since one may have to redo the MO subclass erasing the added methods. They suggest that you should create a Category for each MO that you need additional methods for. However, that solution has problems also since a category cannot have storage variable or properties. So a third solution, I think, is to subclass your NSManagedObject subclasses created from the model. This would allow you to add methods as well as properties or variable if needed. It would also not overwrite work if the original entity subclass is redone.

I’d like to hear other’s thoughts on this.

Thanks,
Jeff


#2

Where in the code is NSManagedObject subclassed for each entity?

From what I remember it is created within BNRItemStore which is a singleton object, therefore will only be one instance of during the lifetime of the application.

Nick
http://myfirstiphoneapp.co.uk


#3

If you have more than one entity it will have its own subclass. I’m not talking about each instance of an entity, just the subclass for each defined entity in the app.