On May 17, 2005, at 11:38 PM, Denis Stanton wrote:
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.
that's OK
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]);
}
I'm not sure why you'd want to do this here.. what class is this?
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
that would call [yourNSArrayController selectedObjects] and that would return you the array of newly selected objects.