我可以在一个表视图中同时使用 cocoa 绑定和委托吗?
Can I use cocoa bindings and delegation at the same time in a tableview?
我对 table 的数据源使用 cocoa 绑定。我的问题是我是否可以使用此 table 的 nstableviedelegate 方法来自定义每个行样式。
据我所知,委托不起作用,没有调用方法,但我不确定我是否正确。
如果是这样,有没有办法将两者结合使用?
What Are Cocoa Bindings?
In the simplest functional sense, the Cocoa bindings technology provides a means of keeping model and view values synchronized without you having to write a lot of “glue code.” It allows you to establish a mediated connection between a view and a piece of data, “binding” them such that a change in one is reflected in the other.
The NSTableViewDataSource protocol declares the methods that an instance of NSTableView uses to provide the data to a table view and allow editing of the contents of its data source object.
NSTableViewDelegate:
A set of optional methods you implement in a table view delegate to customize the behavior of the table view.
使用数据源或绑定来提供数据。您可以在表视图中同时使用 cocoa 绑定和委托。您可以使用绑定来提供数据和数据源来自定义拖放。
我对 table 的数据源使用 cocoa 绑定。我的问题是我是否可以使用此 table 的 nstableviedelegate 方法来自定义每个行样式。
据我所知,委托不起作用,没有调用方法,但我不确定我是否正确。
如果是这样,有没有办法将两者结合使用?
What Are Cocoa Bindings? In the simplest functional sense, the Cocoa bindings technology provides a means of keeping model and view values synchronized without you having to write a lot of “glue code.” It allows you to establish a mediated connection between a view and a piece of data, “binding” them such that a change in one is reflected in the other.
The NSTableViewDataSource protocol declares the methods that an instance of NSTableView uses to provide the data to a table view and allow editing of the contents of its data source object.
NSTableViewDelegate: A set of optional methods you implement in a table view delegate to customize the behavior of the table view.
使用数据源或绑定来提供数据。您可以在表视图中同时使用 cocoa 绑定和委托。您可以使用绑定来提供数据和数据源来自定义拖放。