Re: CoreData Relationships and Array Controllers
Re: CoreData Relationships and Array Controllers
- Subject: Re: CoreData Relationships and Array Controllers
- From: Quincey Morris <email@hidden>
- Date: Sun, 02 Oct 2011 12:02:43 -0700
On Oct 2, 2011, at 10:37 , Amy Gibbs wrote:
> so I tried to bind the table column to the customerBookcase array controller, arranged objects, orderItemProduct.productTitle (orderItemProduct is the relationship between CustomerOrderItems and Product)
Yeah, that obviously can't work, because "orderItemProduct.productTitle" is not a valid KVC key. "orderItemProduct" is a to-many relationship, hence represented by a collection property, and you can't use a collection property anywhere except at the end of a keypath.
What you're trying to do is a 4-level master-detail relationship display, so it's possible you can do it by chaining multiple array controllers together. (Look up the documentation for the "contentArrayForMultipleSelection" binding of NSArrayController for more info. There are also some master/detail tutorial samples out there.) This approach is likely to be fiddly and error-prone, and possibly quite slow.
However, the task of finding all the products for a customer seems to be perfectly suited to a Core Data fetch. You should be able to set a suitable fetch predicate on the array controller. You'd still have to deal with the issue of how you know to update the display when the customer-product information changes, but that's always an issue for data that's structured by to-many relationships, and you'd likely have to solve the problem anyway.
_______________________________________________
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