Re: Figuring out which values are selected in an NSTableView
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 18:21:56 +1200
On May 18, 2005, at 5:50 PM, mmalcolm crawford wrote:
On May 17, 2005, at 10:16 PM, Denis Stanton wrote:
I think you're an inch away from telling me the answer. In fact I'm
sure you are telling me the answer, but you're assuming a little more
understanding on my part.
*If* I understand your situation properly, I think you're
overestimating the complexity of the problem...
I think the problem is that paymentController is not connected or
bound properly. I just don't know exactly what object to select,
what binding to select and what value to enter.
My MyDocumentNib contains icons for File's owner and NSArrayController
My Window contains an NSTableView with columns.
Can you give this me in really simple terms? I don't know the exact
requirement for paymentController outlet to be connected.
Which thing do I select, which binding, and which parameters for that
binding?
*If* all that you want is, in MyDocument, to be able to determine
which objects are selected in the table view, then:
You need a regular outlet from MyDocument (File's Owner) to the
NSArrayController:
IBOutlet NSArrayController *paymentController;
In IB, connect paymentController to the array controller, just as you
would any other outlet to any other object in the nib.
When you need to know what objects are selected in the table view,
simply send paymentController the selectedObjects message:
NSArray *array = [paymentController selectedObjects];
I trust that's all that's required?
Yes, that's all that is required. Unfortunately it's not working.
Something is faulty in my implementation. I have that IBOutlet and I
have dragged from File's Owner to NSArrayControler and clicked connect
so I see Source: paymentController, Destination: NSArray Controller. I
also have Source: window Destination:NSWindow(Window).
And yet [paymentController selectedObjects] remains null
The one thing that I'm not sure about is why you're implementing -
(void)observeValueForKeyPath: (NSString *)keyPath ofObject:
(id)object change: (NSDictionary *)change context: (void *)context?
There may well be a valid reason for it, but given the current context
it does raise a question mark...
The observeValueForKeyPath method is there to handle undo (Cocoa
Programming for Mac OS X, 2nd ed, page 149.)
I didn't include that code in me posting.
I was just using the observeValueForKeyPath method as convenient place
to respond to a change in selection as I see it is being called.
Actually it's being called for an edit, not a mere a selection so I
would need to change it.
Maybe there is a method something like "selectionDidChange" that would
be a better location. I'm still feeling my way through this. I just
put an NSLog message where I expected it would be actioned to
understand what information I could get about the selection.
Unfortunately I have something missing ( or something that shouldn't be
there) that is causing my paymentController to remain null. It's as if
there are two paymentControllers, the one the IBOutlet is bound to and
the one I am interrogating.
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