• 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: Reordering a table insanity
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Reordering a table insanity


  • Subject: Re: Reordering a table insanity
  • From: Quincey Morris <email@hidden>
  • Date: Tue, 27 Nov 2012 22:35:03 -0800

On Nov 27, 2012, at 20:11 , Graham Cox <email@hidden> wrote:

> Maintaining the selection is not really an issue, as I can easily restore it, but I would like this to animate as intended. Any ideas?

I think you can do it like this:

A. Ensure that targetIndex isn't one of the selected row indexes. If it is, change it to the next available unselected row index.

B. Divide your selectedIndexes set into two sets, one containing the indexes less than targetIndex, the other containing indexes greater than targetIndex. Either part of the division could be empty.

C1. Loop over the "less than" set starting from its highest index and working down. At each iteration, move the row at the current index to the targetIndex row.

C2. Loop over the "greater than" set starting from its lowest index and working up. At each iteration, move the row at the current index to the targetIndex row, and increment targetIndex.

Am I crazy or isn't it just that easy? Note that there's no adjustment of indexes necessary, other than the increment of targetIndex in C2.


_______________________________________________

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: Reordering a table insanity
      • From: Seth Willits <email@hidden>
    • Re: Reordering a table insanity
      • From: Graham Cox <email@hidden>
References: 
 >Reordering a table insanity (From: Graham Cox <email@hidden>)
 >Re: Reordering a table insanity (From: Quincey Morris <email@hidden>)
 >Re: Reordering a table insanity (From: Graham Cox <email@hidden>)
 >Re: Reordering a table insanity (From: Graham Cox <email@hidden>)

  • Prev by Date: Re: Reordering a table insanity
  • Next by Date: Re: Reordering a table insanity
  • Previous by thread: Re: Reordering a table insanity
  • Next by thread: Re: Reordering a table insanity
  • Index(es):
    • Date
    • Thread