• 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: Figuring out which values are selected in an NSTableView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Figuring out which values are selected in an NSTableView


  • Subject: Re: Figuring out which values are selected in an NSTableView
  • From: Denis Stanton <email@hidden>
  • Date: Wed, 18 May 2005 15:38:48 +1200


On May 18, 2005, at 1:32 PM, Scott Anguish wrote:


On May 17, 2005, at 8:55 PM, Andrew White wrote:


Have an NSTableView, contents of which are automatically populated using bindings.


Can get the set of rows selected using selectedRowIndexes.

Is there a way to directly get the *values* that are displayed in a particular cell (row & column)? I realise that I can use the selectedRowIndexes to index into the original array used to generate the table and then find the correct sub-entry from there, but I'd rather just use the value if I can.

And what about a sorted table? Does the table transparently preserve the rowIndexes?

if you're using bindings, just get the selected objects directly using the mysteriously named -selectedObjects

Hi Scott

I realise this may seem obvious with experience, but unfortunately it's not clear to me yet. I don't know how to get information on the current selection via the bindings mechanism.
I have an NSTableView and an NSArrayController and they work perfectly well displaying an array and allowing it to be edited and saved. What I don't know is how to get at the values in my application.


The name "selectedObjects" is a useful clue, but I don't know how to use this little piece of information.

I can see that selectedObjects can be sent to an instance of NSArrayController but in my app the lines:

- (void)observeValueForKeyPath: (NSString *)keyPath ofObject: (id)object change: (NSDictionary *)change context: (void *)context {
NSLog(@" selectedObjects = %@", [paymentController selectedObjects]);
}


always return
	selectedObjects = (null)

I guess I'm short of a binding (or two), but I don't know what.

My NSArrayController has one binding.
	Content Array is bound to File's Owner (MyDocument),
	Model Key Path: payments
where "payments" is an MSMutableArray

In my NSTableView each column has a binding of the form
	Bind to  : NSArrayController
	Controller Key :arrangedObjects
	Model Key Path: paymentDate

regards

Denis

Denis Stanton
Orcon Internet Limited
(09) 480 9299
http://www.orcon.net.nz




_______________________________________________ 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
  • Follow-Ups:
    • Re: Figuring out which values are selected in an NSTableView
      • From: Scott Anguish <email@hidden>
    • Re: Figuring out which values are selected in an NSTableView
      • From: mmalcolm crawford <email@hidden>
References: 
 >Figuring out which values are selected in an NSTableView (From: Andrew White <email@hidden>)
 >Re: Figuring out which values are selected in an NSTableView (From: Scott Anguish <email@hidden>)

  • Prev by Date: Re: CoreData and arrays owned by arrays...
  • Next by Date: Re: How best to archive in CSV format
  • Previous by thread: Re: Figuring out which values are selected in an NSTableView
  • Next by thread: Re: Figuring out which values are selected in an NSTableView
  • Index(es):
    • Date
    • Thread