Re: Binding problem with core data
Re: Binding problem with core data
- Subject: Re: Binding problem with core data
- From: Jim Geist <email@hidden>
- Date: Sun, 03 Feb 2013 10:37:00 -0800
On Feb 3, 2013, at 10:06 AM, Keary Suska <email@hidden> wrote:
> On Feb 2, 2013, at 6:25 PM, Velocityboy wrote:
>
>> Finally got a chance to do some more debugging on this.
>>
>> I looked at the referenced object and figured out why the fault, at least. I had tried to bind the subcategory column's Content to category.subcategories, which resolved to a relationship on an NSManagedObject. Under the covers, evidently a relationship is represented as a set, but per the docs, the Content binding has to be to an array (the docs actually say it should be an NSArrayController.)
>
>> So evidently directly binding Content and Content Values to something hanging off a managed object, without going through a controller, is not a great idea.
>>
>> What I don't see is how to express what I want using an array controller, if that's what I have to do. I see two choices:
>>
>> - Bind the array controller for the popup's elements, somehow, to the 'subcategories' relationship for the category object that's selected in each row of the table
>> - Bind the array controller for the popup's elements to the core data entity that represents all of the subcategories, and somehow specify to filter that data per row to just the elements that have a parent of the category that's selected in the row
>>
>> Is it possible to express either of these using just a binding? Or is this case complex enough that I should be looking at doing this part in code?
>
> I re-read your original post and I am not sure what you are actually after. If what you want is, in a table, to display the category and in the same row display a popup of subcategories, you may not be able to accomplish the latter with bindings, but I forget exactly why. You can try binding the column value to controller.arrangedObjects.relationship but I don't know if NSTableView is smart enough to handle it. If it can't (and I suspect that it won't), then you will need to instead handle the popup column manually with NSTableView delegate calls.
Yes, that's exactly what I'm after. Thanks, I'll do it the way you're suggesting.
>
>> On Jan 30, 2013, at 11:23 PM, Quincey Morris wrote:
>>
>>> On Jan 30, 2013, at 22:41 , Velocityboy <email@hidden> wrote:
>>>
>>>> I see two bizarre behaviors: when I change the Category value with the popup button cell in one row, Category values in other rows change. When I change the subcategory, I get an exception:
>>>>
>>>> 2013-01-30 22:32:23.192 Testapp[10506:f03] -[_NSFaultingMutableSet objectAtIndex:]: unrecognized selector sent to instance 0x101d5dfd0
>>>
>>> A NSArray selector is being sent to a NSSet object. That suggests you've forgotten to set the NSArrayController into "entity" mode, which is necessary for a Core Data property, which is modeled as a set rather than an array.
>>>
>>> In "class" mode, the array controller expects its content to be an array; in "entity" mode, it expects the content to be a set.
>
>
> Keary Suska
> Esoteritech, Inc.
> "Demystifying technology for your home or business"
>
>
_______________________________________________
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