我建立一个IOS应用程序,我有以下问题类的关系:CoreData和实施协议
我说一类Animal
含有类Cats
和Dogs
。这些类别又分为DomesticCats
,WildCats
(分别为DomesticDogs
,WildDogs
),其中包含猫和狗的物种,其中一些是家养动物,而另一些则不是。
我有另一个类PetOwner
其中将包含一个对多关系petsSet
要么DomesticCats
或DomesticDogs
的情况下,反比关系是owner
。
有没有在我的应用的CoreDate模型中建立这种关系的方法? 它不是CoreData我会定义一个协议<DomesticAnimal>
,DomesticCats
和DomesticDogs
将实现,包含(其他)属性owner
,但我不认为我可以将它与CoreData模型混合?
或者我需要在我的CoreData模型来创建一个一对多的关系形式PetOwner
到Animal
,但我可以强制执行,只有实现<DomesticAnimal>
类将永远被添加到PetOwner
的petsSet
?