更新时间:2023-02-10 14:40:22
***的方法是使用 获取特定值 并提供带有 的 NSExpressionDescriptionsum:
函数.
The best way is to use a fetch for specific values and supply a NSExpressionDescription with a sum:
function.
当您执行 fetch 时,您会得到一个单元素数组,其中包含一个字典,其键与表达式描述匹配,其值是表达式的结果.在这种情况下,您将获得一个 sum
键,其值将是给定表达式的属性总和.
When you execute the fetch you get a one element array containing a dictionary whose keys match the expression descriptions and whose values are the results of the expressions. In this case, you would get a sum
key whose value would be the sum of the attributes given the expression.