Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有办法在不使用 Core Data 的情况下对输入到表格视图单元格中的值求和?我目前正在使用解析。我想一个更好的问题是如何使用 Parse 获得总和?我真的在这个问题上摸不着头脑。可能需要手持。
您可能可以使用 Key-Value Coding 集合运算符。假设表的行数据是一堆类的实例,Entry并收集在一个NSArray命名的data. 进一步假设每个Entry对象都有一个NSNumber名为的属性cost,这就是您想要总结的内容。然后你可以这样做:
Entry
NSArray
data
NSNumber
cost
NSNumber *sum = [data valueForKeyPath:@"@sum.cost"];
需要明确的是:这确实要求您希望求和的值是支持每一行的对象的属性。