Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bindings and NSTableView example



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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >Bindings and NSTableView example (From: Steve Palmer <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.