• 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
Sorted NSTableView's selectedRow
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Sorted NSTableView's selectedRow


  • Subject: Sorted NSTableView's selectedRow
  • From: "Adam Preble" <email@hidden>
  • Date: Fri, 5 Jan 2007 08:47:03 -0500

Hello all,

I'm have a project with an NSTableView whose content is set through
bindings.  In one of my methods I want to obtain the object selected
in the table and send messages to it.  As the objects are kept in an
NSArray, the only approach in getting the object I can see is:

   [array objectAtIndex: [tableView selectedRow]]

However, this breaks when the table's sort order is changed (by
clicking in the column headers).  The selected row index is wrong for
the array.  I read in a prior message by Sean Murphy (prior to my
membership in the list) that this shouldn't matter:

Referencing objects based upon an index works even when sorting is
permitted.  NSTableViews do not manage data, meaning the model object
itself would have to change its sort order.  If the table was somehow
sorted independently of the data, referencing objects by a row index
would obviously break, but this isn't the case.

It makes sense, but that's not what I'm seeing in my application. When I NSLog the selected row after changing the row order with a sort, I see that it follows what I see selected on screen, not what the order of objects in the data source is. What am I missing?

Thanks,

Adam
_______________________________________________

Cocoa-dev mailing list (email@hidden)

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: Sorted NSTableView's selectedRow
      • From: Jim Correia <email@hidden>
  • Prev by Date: Re: iTunes Database
  • Next by Date: Re: Getting a list of files/folders in a folder/drive
  • Previous by thread: Re: iTunes Database
  • Next by thread: Re: Sorted NSTableView's selectedRow
  • Index(es):
    • Date
    • Thread