On Jul 23, 2009, at 5:05 PM, Ben Lachman wrote:
The problem I'm having is that I can't find a decent way of propagating index changes in the array controller back down to the model. Does anyone have a good method of doing this?
I usually get the array controller's -arrangedObjects as a mutable copy, move the objects in that array, then call a category method I wrote called -reeumerateObjectsByKey: which does as the name suggests. You then ask the array controller to -rearrangeObjects.
Essentially, you're reordering the objects in a "working array", then just rolling through each object setting the new [NSNumber numberWithUnsignedInteger:++index] for the passed in key.
There's probably a better way to do it, but it only took me a few minutes to dream it up and implement it as above and it works perfectly for me and is quite readable / maintainable.
-- I.S. _______________________________________________ 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