On 17 Jul 2012, at 22:41, Markus Spoettl wrote:

> Hello,
> 
>  I have an NSArrayController (automaticallyRearrangesObjects = YES) on which 
> I set a filterPredicate in code (not through bindings). Most of the time, 
> rearranging works but in one 100% reproducible case, the controller produces 
> an empty arrangedObjects array when it should produce a non-empty one.
> 
> It always happens if a certain predicate (A) was set before the predicate 
> that produces the wrong result (B) is set. If any another predicate (or none) 
> is set when setting (B), arrangedObjects is correctly populated. This is 
> completely reproducible.
> 
> When I call rearrangeObjects on the array controller, the result gets 
> rectified. However, even with automaticallyRearrangesObjects = NO, the array 
> controller rearranges automatically so when I rearrange manually after 
> setting the filter, I get two KVO change notifications for arrangedObjects 
> which can be very costly and I'd really like to avoid that.
> 
> Any ideas on how to force NSArrayController to (1) either produce a correct 
> result automatically or (2) prevent to do any rearranging by itself when a 
> filterPredicate is set?

Try subclassing NSArrayController and providing a custom implementation of 
-arrangeObjects:

Even if you do nothing but set a breakpoint and call super, it’ll give you a 
better idea of quite what the rearrangement is doing, and what’s triggering it.


_______________________________________________

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