Re: NSArrayController not rearranging correctly
Re: NSArrayController not rearranging correctly
- Subject: Re: NSArrayController not rearranging correctly
- From: Markus Spoettl <email@hidden>
- Date: Thu, 19 Jul 2012 15:13:13 +0200
On 7/19/12 8:40 AM, Quincey Morris wrote:
2. Use a brute force flag when setting the predicate, something like this:
dontStartExpensiveUpdate = YES;
[_arrayController setPredicate: …];
[_arrayController rearrangeObjects];
// at this point, the KVO notification has been sent up to twice, but ignored
each time
dontStartExpensiveUpdate = NO;
… do the expensive update now …
I ended up doing something similar: I subclassed NSArrayController and added a
flag there. The heavy lifting custom views, which are bound to arrangedObjects,
now check if the object they are bound to is my NSArrayController subclass when
a KVO notification is delivered. If so and the flag is set, they ignore the
observation notification. My NSArrayController subclass implements
-rearrangeObjects which clears the flag first, then calls super.
Of course I sacrifice a little of my perfect view class encapsulation, but it's
justifiable because it makes solving the issue so simple. If only that
NSArrayController bug didn't exist…
Thanks Quincey for the elaborate responses and for confirming the bug.
Regards
Markus--
__________________________________________
Markus Spoettl
_______________________________________________
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