Re: Programmatic initialization of a NSManagedObject with a Relationship
Re: Programmatic initialization of a NSManagedObject with a Relationship
- Subject: Re: Programmatic initialization of a NSManagedObject with a Relationship
- From: mmalc Crawford <email@hidden>
- Date: Sat, 30 Oct 2010 23:02:34 -0700
On Oct 30, 2010, at 4:46 pm, Paul Johnson wrote:
> I have 2 tableviews (A and B) in a window. Both use Core Data. A 3rd
> tableview (in a drawer) has a complete list of items that I can selectively
> Drag and Drop to tableview B. I have almost implemented the Drag and Drop,
> but one step is missing. Tableview B has a Relationship to an item in
> tableview A, and I need to set up that pointer in my tableview B array
> controller (in tableView:acceptDrop:row:dropOperation:). I haven’t figured
> out how to do that yet. Any suggestions?
>
The basic question -- how do you establish a relationship between two managed objects -- is answered in the documentation: <http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CoreData/Articles/cdRelationships.html#//apple_ref/doc/uid/TP40001857-CJBDBHCB>
How you find out the item in Tableview A should be obvious from <http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/DragandDrop/UsingDragAndDrop.html#//apple_ref/doc/uid/20000726-BABFIDAB>.
The Core Data Programming Guide article, however, also notes:
"Core Data does not let you create relationships that cross stores. If you need to create a relationship from objects in one store to objects in another, you should consider using fetched properties."
Given your earlier statement:
On Oct 27, 2010, at 8:38 pm, Paul Johnson wrote:
> *The source table and destination table are each supplied data using
> separate managed object contexts. (The model for the destination table just
> has an additional relationship defined, but the attributes are the same
> otherwise.)
>
If you're using different models for the two table views, presumably you're using two stores...?
mmalc
_______________________________________________
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