Skip navigation.
 
mlRe: Controlling bindings with code
FROM : Trent Jacobs
DATE : Wed Mar 26 09:12:26 2008

Thanks Christiaan.

Why would I expect the filtering to be removed when I unbind? My
understanding is that when an array controller's content is contained in
the arrangedObjects, and that this content is further filtered if the
array controller's 'Content Set' is bound to another array controller.
So I assumed when the binding to the content set is removed the full
contents of the arrangedObjects would be shown. Is this incorrect?

(as a possible clarification, I'm unbinding the content set, not the
arranged objects.)

As for filter predicates... I thought doing it the way I described below
was the proper way since it would mean less code and more reliance on
binding. I guess I was wrong?  :)

Trent.

Christiaan Hofman wrote:
>
> On 25 Mar 2008, at 9:15 PM, Trent Jacobs wrote:
>

>> The app I'm writing is centered around a particular list of objects
>> (for example a list of items in a shop) with various filters allowed.
>> it's a core data app and I'm using bindings wherever possible.
>>
>> In the model I'm using I have an entity for my objects and I've set
>> up relationships to the entities I'll be filtering on (for example
>> brand, colour, whatever).
>>
>> I've got everything with perfectly when I hook up the bindings in IB,
>> i.e. when I select a brand the list of objects is filtered to only
>> show objects of the selected brand. However, when I try to do the
>> bindings in code it doesn't work.
>>
>> To create the bindings I use:
>>
>>        [myObjectController bind : @"contentSet"
>>                        toObject : filterController
>>                    withKeyPath : @"selection.objects"
>>                        options : nil];
>>
>> where myObjectController and filterController are NSArrayController
>> objects and selection.objects represents the relationship in the model.
>>
>> This works fine. However, when I remove the contentset binding I
>> would expect the filtering to be removed.

>
> Why? The -unbind: method does not trigger a reload,
> -bind:toObject:withKeyPath:options: however does. This does make sense
> to me.
>

>> This doesn't happen. What happens is that the list of objects stays
>> the same although the controlling relationship to the filtering array
>> controller is gone, i.e. I change brands and the list stays constant.
>> To remove the bindings I am simply using:
>>
>>        [myObjectController unbind : @"contentSet"];
>>
>> I think this is happening because the NSArrayController is not being
>> told to refresh but i can't find how to force a refresh.
>>

>
> -rearrangeObjects could do it. Or binding to some other property.
>

>> Any ideas?
>>
>> Thanks!

>
> Why aren't you just using filter predicates?
>
> Christiaan
>

Related mailsAuthorDate
mlControlling bindings with code Trent Jacobs Mar 25, 21:15
mlRe: Controlling bindings with code Christiaan Hofman Mar 25, 23:58
mlRe: Controlling bindings with code Trent Jacobs Mar 26, 09:12
mlRe: Controlling bindings with code Christiaan Hofman Mar 26, 11:27
mlRe: Controlling bindings with code Trent Jacobs Mar 26, 12:00