• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
How to create subentity object inheriting from superentity object in core data
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to create subentity object inheriting from superentity object in core data


  • Subject: How to create subentity object inheriting from superentity object in core data
  • From: Leon Starr <email@hidden>
  • Date: Wed, 16 Sep 2009 10:53:01 -0700

I've got a generalization in my core data model with entities named A, B, C let's say where A is a super class with subentities B and C.

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?)

Note: I did create the model programmatically and the subentities have been set properly for entity description "A".

Here's my sad attempt to move forward. As you can see, I've created the objects I need, but B doesn't know that A is it's superclass object. What to do?

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];
Now I have poured through all the related docs, and to my repeated consternation there are a million examples using stupid 1:1 or 1:M relationships but barely a whisper about programmatic entity inheritance. Arggh! Appreciate any help or pointers to whatever I missed in the docs.




_______________________________________________

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


  • Follow-Ups:
    • Re: How to create subentity object inheriting from superentity object in core data
      • From: Quincey Morris <email@hidden>
    • Re: How to create subentity object inheriting from superentity object in core data
      • From: Kyle Sluder <email@hidden>
  • Prev by Date: Re: Upgrading NSDocument format, best practice
  • Next by Date: Re: [myNSWindow setDocumentEdited:dirtyB] fail ??
  • Previous by thread: Re: settings to build for 10.5 on 10.6?
  • Next by thread: Re: How to create subentity object inheriting from superentity object in core data
  • Index(es):
    • Date
    • Thread