• 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: Howto access model element from NSTableView selection ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Howto access model element from NSTableView selection ?


  • Subject: Re: Howto access model element from NSTableView selection ?
  • From: Matt Neuburg <email@hidden>
  • Date: Sun, 07 May 2006 18:36:30 -0700
  • Thread-topic: Howto access model element from NSTableView selection ?

On Mon, 8 May 2006 01:13:49 +0200, Pierre CHATEL <email@hidden>
said:
>Hi List,
>
>i have an application with an NSTableView displaying the content of
>an already existing array. I'm using an NSArrayController and
>bindings to fill the columns of my tableview.
>
>When i sort the content of the tableView by clicking on a column
>title, only the view is sorted, not the content of the array... which
>is great from an MVC standpoint.
>
>But how do i know which element of the array is selected when the
>user of my application double-click on a row of the tableview ?
>I can't rely on the click index since the view has been sorted but
>not the model array.
>Is there a way to access the displayed value of a row in a column
>without using the view's dataSource ?

Use the NSArrayController's selectionIndexes and arrangedObjects. I was
reluctant to do this, perhaps for the same reason you are, but in the end I
just did it anyway after getting this very helpful answer (from mmalc) to
the same question:

<http://www.cocoabuilder.com/archive/message/cocoa/2006/3/6/158099>

See also my response here, contemplating my options:

<http://www.cocoabuilder.com/archive/message/cocoa/2006/3/6/158148>

m.

--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: -[NSEvent window] for NSPeriodic event?
  • Next by Date: Re: object type testing
  • Previous by thread: Howto access model element from NSTableView selection ?
  • Next by thread: Implementing control with multiple cells
  • Index(es):
    • Date
    • Thread