Re: Bindings and NSTableView example
Re: Bindings and NSTableView example
- Subject: Re: Bindings and NSTableView example
- From: Tim Lucas <email@hidden>
- Date: Wed, 1 Jun 2005 12:55:58 +1000
On 01/06/2005, at 12:00 PM, Steve Palmer wrote:
Is there a simple step-by-step example of how to use bindings to
connect the columns of an NSTableView to a class that stores the row
values in an NSArray of objects? All the examples I've seen tend to
cover more involved uses of bindings that obfuscate the simple example
of how make them work. And none of them explain how to plumb the bits
and pieces in Interface Builder.
Right now I've tried experimenting and deciphering the examples in the
Apple documentation but I can't get it to work. I'm considering going
back to the use of dataSource which seems much simpler for my purposes
but I'd like to have one last stab at solving this problem.
Here's an example that just uses NSMutableDictionary's for the rows:
- Drag+drag an NSArrayController into your nib.
- Go to attributes of the array controller and add the key 'firstName'
and 'lastName'
- Drag+drop an NSTableView into your window
- Select the first table view header, and go to the bindings panel in
the attribute inspector (apple-shift-i)
- Bind the 'value' binding of the tableview header to:
"Bind to: NSArrayController"
"Controller key: arrangedObjects"
"Model key path: firstName"
- Repeat for the second column, binding instead to "lastName"
- Drag a drop an new NSButton into your window
- Change the title of the button to "Add"
- Make a connection from the button to the "Add" action of the
NSArrayController
File -> Test Interface
- tim lucas
_______________________________________________
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