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
Core Data, Bindings, and default relationships
[
Date Prev
][
Date Next
][
Thread Prev
][
Thread Next
][
Date Index
][
Thread Index
]
Core Data, Bindings, and default relationships
Subject
:
Core Data, Bindings, and default relationships
From: Christopher Frederick <
email@hidden
>
Date: Mon, 20 Jun 2005 22:42:16 -0700
This is a question concerning default connections between new entities created via the add: IBAction defined in NSArrayController; specifically, is there any way to bind a relationship defined for an entity created by one NSArrayController to the selected entity of another NSArrayController? For example, if one were to model a Purchase entity with a to-many relationship to Item entities, which themselves have a to-one relationship to a purchase, and using bindings it was desired to add an item to a purchase by using an NSButton connected to the add: action of an Item NSArrayController, how would one go about initializing that initial to-one "purchase" relationship of the Item entity to the currently selected Purchase entity? I suppose that I made that sound more complicated than it really is, so please allow me to summarize:
(1) Purchase entity, to-many relationship to Item entity named "items"
(2) Item entity, to-one relationship to Purchase entity name "purchase"
(3) NSArrayController, Entity Name Attribute: Item
(5) "Add Item to Purchase" NSButton, bound to aforementioned NSArrayController's add: action
(6) No way to set Item.purchase to currently selected Purchase!
Or is there?
Initially, I had thought that perhaps using a custom class for Item with a re-implementation of the awakeFromInsert method to set the relationship would work, until I realized that the new Item entity has no way of extracting the currently selected Purchase, via the active managed object context, from another NSArrayController bound to the Purchase Entity. Okay, so, I can always subclass NSArrayController and re-implement addObject to set the relationship then, right? Well, no, not really, because from what I've garnered on the 'net so far, it appears that subclassing NSArrayController isn't really A Good Idea. Besides, how could my custom Item controller be aware of the Purchase controller, let alone extract the current selection from it? And so, I find myself at a rather unfortunate impasse.
Am I missing something elementary, or have I stumbled upon a deeper problem with Core Data bindings? Thanks in advance for any information.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
Follow-Ups
:
Re: Core Data, Bindings, and default relationships
From:
Chris Hanson <email@hidden>
Prev by Date:
Re: NSFileManager - getting list of "safe" files/folders
Next by Date:
Re: Loading an RSS (feed://) URL
Previous by thread:
Re: Event driven parsing and xml validation
Next by thread:
Re: Core Data, Bindings, and default relationships
Index(es):
Date
Thread