user3193123
user3193123

Reputation: 13

What is the simple way to bind an NSMutableArray to a single Colum NSTableView

Is there a simple way to bind a NSMutableArray made up of Strings to a Single column NSTableView without creating any new classes?

Upvotes: 0

Views: 440

Answers (2)

Andrew Madsen
Andrew Madsen

Reputation: 21373

Assuming you're using a view-based NSTableView, you must bind the entire table view (not the column) to the array controller's arrangedObjects. Then, bind the text field's value to the containing cell view's objectValue property.

This is documented here.

For cell-based NSTableViews, Amy Worrall's answer is the correct approach.

Upvotes: 1

Amy Worrall
Amy Worrall

Reputation: 16337

Make an NSArrayController in interface builder. Bind its Content Array to your mutable array, like so:

Binding

Then bind your table column to that array controller, like so:

Binding2

(Note the self in the model key path field. That's what makes it work with an array of strings.)

Upvotes: 2

Related Questions