NSArrayController绑定NSTableView的方法

来源:互联网 发布:明通网络数码科技 编辑:程序博客网 时间:2024/05/16 14:28

NSArrayController绑定NSTableView的方法

1.在File’s Owner中創建NSMutableArray *employees

NSArrayController操作

2.拖NSArrayController到Object的列表

3.設置Attributes inspector->Object Controller, Mode選擇Class, Class Name填寫次array中object的類名字, 在 Keys中添加Object中需要現實的變量名字

4.在Binding inspector中,Controller Content點選content array設置Bind to,选择File’s Owner,在Model Key Path中填入1中Array的名字

NSTableView操作

5.拖NSTableView到nib中,點選table的一列,在Binding inspector->Value中點擊設置Bind to,

   Controller Key設置為arrangedObjects, Model Key Path設置3步中的Object變量名字

6.将NSTableView设置为cell-based (NSTableView->Attributes inspector->TableView->Content Mode选择即可)

    View based模式貌似不支持!!!

7.拖动Button,关联Acttion到NSArrayControler的Add和Remove动作等,实现自动操作。

   需要访问时,可从employees中找到TableView中所有的对象


0 0
原创粉丝点击