Core Data Derived Attributes with a sum function

ⅰ亾dé卋堺 提交于 2020-12-14 23:46:43

问题


I have two entities in my app: User & Expense. A user has many expenses. Expense as an attribute amount (of type Int32).

I added a derived attribute expensesCount (of type Int16) on the user to count the number of expenses, using the derivation expenses.@count. It's working fine, the app compiles, launches, and when I save a relationship, the value for the expensesCount attribute is updated.

I also added a derived attribute expensesAmount on the user to count the total amount of all related expenses. I use the derivation expenses.amount.@sum. The app compiles but crash at launch with the following error:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'currently unsupported (unsupported function on to many (not count or sum))'

Any idea why?

PS: I also tried another synthax recommended on Twitter sum:(expenses.amount), but I got the same crash: https://twitter.com/numist/status/1181686971892031488?s=21

来源:https://stackoverflow.com/questions/64750427/core-data-derived-attributes-with-a-sum-function

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!