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: Leon Starr <email@hidden>
- Date: Wed, 16 Sep 2009 11:16:45 -0700
Hmm. Does that mean that I only need to create the subclass entity B
as shown?
// NSEntityDescription *aEntity = [[model entitiesByName]
objectForKey:@"A"];
NSEntityDescription *bEntity = [[model entitiesByName]
objectForKey:@"B"];
//A *newA = [[A alloc] initWithEntity:aEntity
insertIntoManagedObjectContext:context];
B *newB = [[B alloc] initWithEntity:ATC_Entity
insertIntoManagedObjectContext:context];
So now that I have a newB (no pun intended) I can use that to access
the superclass attributes just like normal inheritance, right? I'm
about to try it anyway, but if it would be helpful to know if this is
the correct thinking.
On Sep 16, 2009, at 11:02 , Kyle Sluder wrote:
On Wed, Sep 16, 2009 at 10:53 AM, Leon Starr
<email@hidden> wrote:
A is not abstract, so if I create an A NSManagedObject, I need to
create and
relate a single B or C subclass object. How do I make this happen?
I can
create the entities, but HOW do I tell the model that object B is a
subclass
of object A (or vice versa?)
You don't need to tell it anything. Core Data knows that every B
isa A.
--Kyle Sluder
_______________________________________________
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