Re: Model index and Array Controller index
Re: Model index and Array Controller index
- Subject: Re: Model index and Array Controller index
- From: "I. Savant" <email@hidden>
- Date: Thu, 23 Jul 2009 18:51:18 -0400
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 (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