> On 23 Jun 2016, at 17:51, Quincey Morris 
> <quinceymor...@rivergatesoftware.com> wrote:
> 
> 
>> My workaround was to set controller.clearsFilterPredicateOnInsertion == YES 
>> and reset the filterPredicate following -addObject:
>> 
>> It might be possible to subclass NSArrayController …
> 
> There’s no need to work around at all. The correct, straightforward solution 
> is to update the content array (i.e. the unfiltered objects being managed via 
> the array controller) directly in a KVO compliant manner, using 
> ‘mutableArrayValueForKey:’.
> 

Do you mean something like this?

NSMutableArray *proxy = [NSArrayController mutableArrayValueForKey:@"content"];
[proxy addObject:object];
[proxy filterUsingPredicate:self.filterPredicate];

This does work but is very slow even with a small collection (the subclass 
returned is an instance of NSKeyValueSlowMutableArray).
Perhaps NSArrayController does not override all the required KVC  methods for 
the content key?

[self.submissionsArrayController addObject:object];
self.submissionsArrayController.filterPredicate = self.filterPredicate;

The above amounts to the same thing and seems much more performant.

I suppose I could make my NSViewController class KVC compliant for the content 
array but that seems overkill in this case.

Thanks

J


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to