• 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: Sorting issues with NSTableView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sorting issues with NSTableView


  • Subject: Re: Sorting issues with NSTableView
  • From: Keary Suska <email@hidden>
  • Date: Wed, 18 Jul 2007 09:37:01 -0600
  • Thread-topic: Sorting issues with NSTableView

on 7/18/07 8:14 AM, email@hidden purportedly said:

> The display sorts the files listed correctly but the indexes of the selected
> files, once sorted, do not point to the correct place in the actualy array.

As you see, table sorting doesn't change the order of the model array.

> I manually update the array when files are added/removed (using
> "willChangeKeyForValue"/"didChangeKeyForValue").  The array itself is just a
> wrapper on a string, to hold the name of the file, with a 'value' accessor
> that returns the file name.
>
> The display updates fine, the list is sorted correctly and all files are
> listed etc.. but once sorting occurs, the indexes returned no longer
> correspond to the correct file in the array itself.  This seems strange
> since the display is getting the data correctly from the array, but then
> returning a different index.
>
> For example, my "Remove" button gets a list of the selected indexes and
> tries to remove those selected 'files' from the list, but it is not possible
> because I can't correlate the indexes returned from the display with the
> objects they are supposed to point to in the array.
>
> How do i find the object in the array associated with the index returned
> from the display?  Is there a way to sort the array when the column is
> sorted so that the indexes always match? This seems overkill though.  Is
> there a setting in the array controller I am not setting properly?

It sounds like your approach is a good candidate for implementing indexed
accessor methods. This way you can use the controller's action method(s),
such as -remove:, and capture when they happen.

Otherwise, you will need to manually determine indexes using
-indexOfObject:, getting the controller's select objects using
-selectedObjects:.

Best,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"


_______________________________________________

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: Sorting issues with NSTableView
      • From: "Patrick M" <email@hidden>
References: 
 >Sorting issues with NSTableView (From: "Patrick M" <email@hidden>)

  • Prev by Date: Re: Maintaining a List of instances of a class
  • Next by Date: Tracking Rectangle Bounds
  • Previous by thread: Sorting issues with NSTableView
  • Next by thread: Re: Sorting issues with NSTableView
  • Index(es):
    • Date
    • Thread