I've got a situation where sorting an array using sort descriptors is slow. The 
number of items being sorted is not enormous - about 2,000 - but there could be 
several sort descriptors and the main string one is using a localized and 
natural numeric comparison. I cache the results and take a lot of care only to 
resort when needed, but that doesn't help on the first run through which often 
takes in the order of 10-20 seconds. The interface that displays the results 
therefore beachballs for this time.

I'm considering using threads to help, where a thread is used to perform the 
sort itself, and until the sort has finished the UI can display a busy 
indicator (indeterminate circular progress indicator) next to the selected row 
in the table. This is in the master table of a master-detail interface where 
the detail displays the sorted items selected. While busy the detail view can 
be blank or show the previous arrangement.

So my question is, is threading a good solution? While NSMutableArray isn't 
marked as thread-safe, the array in question can be arranged to not be used 
outside of the sorting thread, and only substituted for the returned sorted 
items when complete. Or can array sorting not be done on a thread at all?

 --Graham


_______________________________________________

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

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

Reply via email to