• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Model index and Array Controller index
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread 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


  • Follow-Ups:
    • Re: Model index and Array Controller index
      • From: Ben Lachman <email@hidden>
References: 
 >Model index and Array Controller index (From: Ben Lachman <email@hidden>)

  • Prev by Date: Re: Comparing NSImages
  • Next by Date: Confusion about Lablel Font Size: 13 or 10 ?
  • Previous by thread: Model index and Array Controller index
  • Next by thread: Re: Model index and Array Controller index
  • Index(es):
    • Date
    • Thread