简体   繁体   中英

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

有没有一种简单的方法可以将由字符串组成的NSMutableArray绑定到单列NSTableView而不创建任何新类?

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

捆绑

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.)

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM