ios - How to have two NSManagedObject classes with the same superclass -


i have 2 classes, mammals , fish, both inherit general superclass, animals. i'd store mammals , fish using core data, i've made them both subclasses of nsmanagedobject. so, when want mammals , fish, execute couple fetch requests.

my question animals superclass.

  • it's properties , methods used 2 subclasses, should nsmanagedobject well?
  • if so, mammals , fish need explicit nsmanagedobject subclass because subclass animals?
  • is approach flawed?

sorry if super-basic question, if answer "yes; no." 1 of answers here warned against using inheritance in data model, hence apprehension.

make own decision whether inheritance model tie in knots in future. in direct answer question inheritance tree like...

 nsmanagedobject -> animal -> mammals                             -> fish 

so

@interface animal : nsmanagedobject

and

@interface fish : animal

just wary core-data not take complex rearrangement if need upgrade model in future , still hang on existing data. not impossible, not easy.


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -