• 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: mmalc crawford <email@hidden>
  • Date: Wed, 18 Jul 2007 09:46:27 -0700


On Jul 18, 2007, at 7:14 AM, Patrick M wrote:
If I select B, this will correspond to index 1 in the display, but index 3
in the array. How can I map the display index to the array index without
creating my own code?


You can't -- you have to write some code.
Using bindings does not mean you don't ever have to write code.

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.


It's not clear in what sense this is "strange"?
The table view is presenting a representation of the data. In the cases of sorting and filtering, it does not actually change the data.


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.


Is there any reason why you cannot simply ask the array controller to remove the items?
e.g. connect the Remove button to the remove: method of the array controller, or send the array controller a removeObjectsAtArrangedObjectIndexes: message?


How do i find the object in the array associated with the index returned
from the display?


id objectAtTheDisplayIndex =
	[[arrayController arrangedObjects] objectAtIndex:theDisplayIndex];


mmalc

_______________________________________________

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: NSScreen + resolution change
  • Next by Date: Getting PDF data from a webView
  • Previous by thread: Re: Sorting issues with NSTableView
  • Next by thread: Re: Sorting issues with NSTableView
  • Index(es):
    • Date
    • Thread