最佳答案
在 Objective-C 中,有一种使用KVC 集合运算符 的非常方便的方法:
NSNumber *sum = [sharedData.orderItems valueForKeyPath:@"@sum.Quantity.integerValue"];
NSInteger integerSum = sum.integerValue;
其他简单的运算符是:
@count
- 对象数@avg
- 平均值@max
- 最大值@min
- 最小值
关于ios - 从对象中检索值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44476804/