开发者

What is the best way to create derived properties

I have a datamodel with to-many to-many relations. Using the example of employee database let say the entity开发者_开发问答 division is related to department which in turn is related to employee. The employee has an attribute salary. How best to have a attribute at the level of division which is derived from the salary attribute. For example average salary or maximum salary.

I would need those attributes to sort the list of departments.


Have a look at this question in the Core Data FAQ. If you can't do it with KVC set/array operators, then you try to do the keyPathsForValuesAffectingValueForKey : trick. If that isn't viable, you have to use KVO to observe changes in the key path the value is derived from.


Have a look at the KVC Set and Array Operators. Using one of these (@avg in your example) wrapped in a custom read only property should fit the bill.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜