2

In my ios application I had many model classes like ProjectLead,TeamLead,ProjectManager,Developer and all these classes are extending Employee base class.

class Employee{
string name,age,company;
}

class ProjectLead: Employee{
  string pl_1,pl_2,pl_3;
}

class TeamLead:Employee{
string tl_1,tl_2,tl_3;
}
class ProjectManager:Employee{
string pm_1,pm_2,pm_3;
}
class Developer:Employee{
string d_1,d_2,d_3;
}

I can create individual Entity for all my 5 model classes. Will I need to give the parent entity attributes for the child entity. How can I achieve inheritance in Entity definitions in EntityModel

for example Creating ProjectManager Entity

I can add pm_1,pm_2,pm_3 as its attributes, since its extends Employee I have another 3 attributes like name,aga,company. while creating ProjectManage entity Will i have to create it with 3 attributes or 6 attributes?

I just want to create Entity for my model class as like http://www.raywenderlich.com/934/core-data-tutorial-for-ios-getting-started

Richa
  • 238
  • 1
  • 3
  • 16
Sridhar
  • 2,228
  • 10
  • 48
  • 79

1 Answers1

3

Take a look at this post, it explains how to use inheritance in core data. https://byunsoo.wordpress.com/2013/03/27/inheritance-in-core-data/

When you create an entity, (e.g Project Lead), you can select the parent entity (e.g Employee) in the Data Model inspector.

It does have some trade offs though, do go through them too.
Core Data entity inheritance --> limitations?

Community
  • 1
  • 1
Richa
  • 238
  • 1
  • 3
  • 16