Cocoa绑定 - 为所有孩子的属性获取@sum [英] Cocoa bindings - get @sum for an attribute for all children

查看:198
本文介绍了Cocoa绑定 - 为所有孩子的属性获取@sum的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经尝试让这个工作一段时间了。

I've been trying to get this to work for a while now.

在我的核心数据模型中,我有:

In my Core Data model I have:

实体公司雇员

Company.employees
Employee.age

使用绑定我想显示所有 employees 公司在一个tableView。

Using bindings I would like to show the sum of age for all employees when clicking on a Company in a tableView.

我尝试了变化: @distinctUnionOfSets .employees。@ sum.age ,但不能让它工作。

当我尝试上面的时候,我得到错误信息:
[< _NSFaultingMutableSet 0x10019c430> removeObserver:forKeyPath:]不支持。键路径:@ sum.age

I've tried variations of: @distinctUnionOfSets.employees.@sum.age, but can't get it to work.
When I try the above I get the error message: [<_NSFaultingMutableSet 0x10019c430> removeObserver:forKeyPath:] is not supported. Key path: @sum.age

我的 NSArrayController 绑定到 Client 所以在IB它看起来像这样: Clients.selection。@ distinctUnionOfSets.employees。@ sum.age

My NSArrayController is bound to Client so in IB it looks like this: Clients.selection.@distinctUnionOfSets.employees.@sum.age

任何想法?

推荐答案

添加了一个绑定到Employee的新NSArrayController。

I made this more complicated than it was. Added a new NSArrayController which was bound to Employee.

这篇关于Cocoa绑定 - 为所有孩子的属性获取@sum的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆