• 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
subentity key undefined after merging models
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

subentity key undefined after merging models


  • Subject: subentity key undefined after merging models
  • From: "Eric Miller" <email@hidden>
  • Date: Thu, 8 Mar 2007 10:22:28 -0700

Hi list -

I recently decided to refactor parts of my app under development to
allow chunks of behavior to live in plugins. As part of this, I broke
up my Core Data model so what was once sprawling and working is now
nicer to look at (and relevant parts are accessible to plugins) but
not working.


I have an entity named VizMirror which is the superentity for a few other entities. DCamera is one such entity. Before refactoring DCamera was just a subentity of VizMirror in my monolithic .xcdatamodel.

After refactoring, the VizMirror entity and its associated
NSManagedObject subclass live in a framework and the Camera entity
lives in the app. The app links to the framework and at run time the
app merges the two .mom models and reunites the entities by calling
VizMirror's setSubentities. Examining the entity descriptions confirms
that the model seems to be in the right state.

But then when I attempt to insert a DCamera into my managed object
context, it throws an exception with the error that DCamera is not
key-value coding compliant for an attribute defined in the VizMirror
entity. This was working before breaking up the model. It *should*
still work, right?

The class-wise inheritance chain mirrors the entity chain and goes like this:
- NSManagedObject
  - VizMirror
     - DCamera


This bit of code is in my NSPersistentDocument subclass in initWithType:error:. I've edited it, of course. The model returned from generateModelWithPlugins: is, as I said, apparently identical to the model pre-refactoring, wrt DCamera and VizMirror.

---------------------
/* ... */
NSManagedObjectModel* mom = [ DataModelWrangler
generateModelWithPlugins:plugins ];
NSManagedObjectContext *moc = [ [ NSManagedObjectContext alloc ] init ];
NSPersistentStoreCoordinator* psc = [ [ NSPersistentStoreCoordinator
alloc ] initWithManagedObjectModel:mom ];

[ moc setPersistentStoreCoordinator:psc ];
[ self setManagedObjectContext:moc ];

[ [ moc undoManager ] disableUndoRegistration ];

NSEntityDescription* camEntity = [ [ mom entitiesByName ]
objectForKey:@"DCamera" ];
DCamera* defaultCam = [ [ DCamera alloc ] initWithEntity:camEntity
insertIntoManagedObjectContext:moc ];
----------------------

The call to initWithEntity:insertIntoManagedObjectContext: is what throws:

[<DCamera 0x14a83b0> valueForUndefinedKey:]: this class is not key
value coding-compliant for the key guid.

Where guid is, again, an attribute of the VizMirror entity.

So I don't know ... is there anything obviously wrong with what I'm doing?

thanks!
Eric Miller
_______________________________________________

Cocoa-dev mailing list (email@hidden)

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: subentity key undefined after merging models
      • From: mmalc crawford <email@hidden>
  • Prev by Date: NSTableHeaderCell overlaps when printing
  • Next by Date: Re: Minimal cocoa application
  • Previous by thread: NSTableHeaderCell overlaps when printing
  • Next by thread: Re: subentity key undefined after merging models
  • Index(es):
    • Date
    • Thread