是否有可能有一个结合多个关键路径的绑定?
假设我有一个具有数量值的对象。
另外,我有一个数组控制器,它保存这些对象的数组。
此外,我有一个表,其中包含总列的百分比(即给定行的数量占所有行数量总和的百分比),需要通过绑定填充正确的值。
那么似乎执行此操作的想法方法是将此列绑定到 [电子邮件] protected] 除以 arrayController.arrangedObjects.quantity。
是否有可能做到这一点?
如果没有,你能建议一种替代方法来达到同样的目的吗?
Lets say I have an object which has a quantity value.
Also, I have an array controller which holds an array of these objects.
Furthermore, I have a table which has a percent of total column (i.e. the given row's quantity's percentage of the sum of the quantities for all rows), which needs to be populated with the proper value via bindings.
It would then seem that the idea way to do this would be to bind this column to [email protected] divided by arrayController.arrangedObjects.quantity.
Is it possible to do this?
If not, can you suggest an alternative means of achieving this same end?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一种方法是实现自定义数字格式化程序,并为除数进行自定义绑定,以编程方式绑定到 arrayController.arrangedObjects.quantity 。 在格式化程序的
setObjectValue:
方法中,您将执行除法并将结果传递给super
。One way would be to implement a custom number formatter, with a custom binding for the divisor, programmatically bound to
arrayController.arrangedObjects.quantity
. In the formatter'ssetObjectValue:
method, you would perform the division and pass the result tosuper
.