I’m a bit new to core data and am currently trying to utilize parent entities.
Right now, I have this kind of model
Entities:
ThemePark -> hasAttractions (one to many relationship)
WaterPark -> hasAttractions (one to many relationship)
Attractions -> inThemePark (inverse relationship of hasAttractions)
Attractions -> inWaterPark (inverse relationship of hasAttractions)
What I want to have is a parent entity, let’s say GenericPark, that has the property "hasAttractions", but I’m not sure how the inverse relationship should be defined.
If I do the following
Attractions -> inGenericPark (inverse of hasAttractions in GenericPark)
how can I figure out whether the GenericPark is a waterPark or a ThemePark?
How should I go about revising this model while utilizing parent entities?
Thanks in advance!!!
You should assign a custom class to each entity in the Data Model Inspector (which can have the same name as the entity), and create NSManagedObject subclasses for each entity (if you have not done that already).
Then
ThemeParkandWaterParkare both subclasses ofGenericParc, and you can test aGenericParcobject e.g. with