取数组中的最大值
iOS中提供了一种便捷的数组求和、求最大最小值以及平均值的方法,当然还有其他的,我看官方文档的时候粗略看了一下,其他的那几个英文单词看不懂就不研究了
int max = [[array valueForKeyPath:@"@max.intValue"] integerValue];
同理,最小值就把max改成min
求平均值 avg
求和 sum
[[array valueForKeyPath:@"@min.intValue"] integerValue]
[[array valueForKeyPath:@"@avg.intValue"] integerValue]
[[array valueForKeyPath:@"@sum.intValue"] integerValue]