在NSArray中查找最大数值 [英] Finding maximum numeric value in NSArray
本文介绍了在NSArray中查找最大数值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有NSNr的NSNrray并希望在数组中找到最大值。这样做有内置的功能吗?我正在使用iOS4 GM,如果这有任何区别。
I have an NSArray of NSNumbers and want to find the maximum value in the array. Is there any built in functionality for doing so? I am using iOS4 GM if that makes any difference.
推荐答案
KVC方法如下所示:
The KVC approach looks like this:
int max = [[numbers valueForKeyPath:@"@max.intValue"] intValue];
或
NSNumber * max = [numbers valueForKeyPath:@"@max.intValue"];
数字作为NSArray
with numbers as an NSArray
这篇关于在NSArray中查找最大数值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文