4

Is it posible to configure superclass for CoreData Entities subclassing? I want to change NSManagedObject to my subclass of NSManagedObject.

Thanks

rokstar
  • 404
  • 1
  • 3
  • 12
  • Yes, you can, you can set an entity to be abstract in core data and then define subclasses of it. Will try to find docs. Try this... http://stackoverflow.com/questions/11385306/abstract-entities-and-inheritance-in-core-data – Fogmeister Apr 08 '13 at 07:50
  • No, I mean following: 1. Subclass NSManagedObject 2. Configure CoreData for using my subclass for all objects and superclass when I create specific classes for entities – rokstar Apr 08 '13 at 07:56
  • Why would you want to do that? – Fogmeister Apr 08 '13 at 07:58
  • In my app I have a lot of business entities, but these entities are dictionaries, sales, appointments and so on, and every this kind has own base logic, that wy I want to implement it inside superclass – rokstar Apr 08 '13 at 08:13
  • You can use whatever subclass of NSManagedObject you want to. Just type it into the entity definition. You can't set it once and have it always happen, though; you have to do it for each and every entity. – Bored Astronaut Nov 23 '13 at 15:50
  • 1
    It's may not a good idea to setup an abstract entity in NSManagedObjectModel, and then link all entities as a subclass of it. Because core data will map all these sub-entities into one table, and may cause performance issue. – Lei Zhao Jan 14 '15 at 22:54

1 Answers1

0

You can subclass NSManagedObject and set it as the class e.g. MyManagedObject in the image below but you will still have to set this for all the entities in your datamodel. There is no way to set your own managed object class which can be used for all entities by default it can only be NSManagedObject.

enter image description here

evanescent
  • 1,373
  • 13
  • 20