Re: NSArrayController not rearranging correctly
Re: NSArrayController not rearranging correctly
- Subject: Re: NSArrayController not rearranging correctly
- From: Quincey Morris <email@hidden>
- Date: Wed, 18 Jul 2012 23:40:09 -0700
On Jul 18, 2012, at 23:22 , Markus Spoettl wrote:
> That doesn't sound right. The array controller is used by views directly, they bind to arrangedObjects (like in the example). Since when is it recommended to insert an intermediate object between table view and NSArrayController? Makes the whole binding idea rather useless, or am I missing something?
I wasn't thinking about inserting an intermediate object there. Rather, I was thinking of two techniques (and I am sure there are plenty of others) for preventing KVO operations from triggering unwanted expensive updates:
1. Use the cancelPerform/performSelector…afterDelay:0 pattern to defer the expensive operation until the next run loop iteration AND prevent it from being queued more than once.
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 …
Suggestion #1 would coalesce all rearrangements during a single run loop iteration (including multiple content changes). Suggestion #2 would just work around the rearrangement behavior.
_______________________________________________
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