objective c - Possible to set multiple parent entities for Core Data NSManagedObject? -
i have created following example core data nsmanagedobject subclasses:
pbcommentableobject : nsmanagedobject // allow comments on object @property (nonatomic, retain) nsset *pbcomments; // unordered set of pbcomment objects pbcomment : pbcommentableobject // allow comments on comment @property (nonatomic, retain) pbcommentableobject *target; pblist : pbcommentableobject // allow comments on list @property (nonatomic, retain) nsorderedset *pbordereditems; // ordered set of pblistableobject objects pbstring : pblistableobject // allow strings added lists @property (nonatomic, retain) nsstring *pbtext; pblistableobject : ???? // i'd both pblist , pbstring pblistableobjects @property (nonatomic, retain) pblist *pblist; the problem having following behavior:
- lists (
pblist) can hold ordered list of strings (pbstring) or other lists (pblist). - allow comments (
pbcomment) on lists (pblist) , other comments (pbcomment) not strings (pbstring)
is possible do? trying build core data model via visual interface in xcode; , while conceive of using categories, don't know how without xcode spitting out warning when fail define relationship via visual editor.
i think stretching idiom of inheritance. "listable" , "commentable" results in quite unreadable complexity.
the validation of allowing or disallowing comments, lists or have you, can modeled using (boolean) attributes , relationships. try think of concrete objects such "comment" or "string" , model lists attribute sets.
Comments
Post a Comment