Re: How to create subentity object inheriting from superentity object in core data
Re: How to create subentity object inheriting from superentity object in core data
- Subject: Re: How to create subentity object inheriting from superentity object in core data
- From: Ben Trumbull <email@hidden>
- Date: Wed, 16 Sep 2009 22:20:11 -0700
Okay, my understanding, then, is that the inheritance is just in the
model - makes sense. If you subclass NSManagedObjects for the parent
and child entities, you need to explicitly declare and synthesize
(dynamically) all common properties you want to access at lower levels
of the hierarchy (at least).
entity inheritance is just in the model. class inheritance still
applies normally.
Just to be clear, in the model I've got Entities: Auto, Sedan, Truck
and the parent (Auto) has a common property license. Now when I get a
pointer to a Sedan or Truck I want the ability to access via
thisTruck.license or thisSedan.license. In fact, if I end up with a
pointer (Auto *) thisAuto, I want thisAuto.license as well.
To get this to work, without KVC, I need to declare @property/
@dynamic for license in Auto, Sedan and Truck. (Can't just put it in
Auto and expect Sedan.license to work). No big deal unless I have a
bunch of common properties in the parent entity.
No, Objective-C properties are inherited by subclasses. If you use
the modeling tools, your model will be created correctly, and your
custom NSManagedObject subclasses will have the correct @interface
definitions. Even if you need to do all this programmatically, I'd
recommend to play with the modeling tools more to see what things are
supposed to look like.
- Ben
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden