【发布时间】:2011-11-17 23:40:23
【问题描述】:
我想将包含 int 值的数组与数字进行比较
示例 [1,2,30,1,40,200,10,500]
我该怎么做?
提前感谢
我这样做了,但它说操作数无效:
if ([placeName count])
{
for (int i =0; i < [placeName count]; i++)
{
NSArray *sortedArray=[placeName sortedArrayUsingFunction:intSort context:NULL];
self.placeName = [NSMutableArray arrayWithArray:sortedArray];
NSMutableArray *tempArray = [sortedArray objectAtIndex:i];
NSDecimalNumber *Distance = [tempArray objectForKey:@"distance"];
NSMutableArray *intDistanse=[Distance intValue];
DLog(@"Distance%d", intDistanse);
NSMutableArray *intDistanse=[Distance intValue];
DLog(@"Distance%d", intDistanse);
for(int j = 0; j < [intDistanse count]; j++)
{
if ( intDistanse[j] < 500 ) //here its says error
{
DLog(@"success");
}
}
}
}
【问题讨论】:
-
只需循环遍历数组的长度,将每个元素与给定的数字进行比较...初学者的问题!
-
是的初学者问题:)
-
请检查我编辑的问题!谢谢
-
你不能再声明整数i了!改变它!!!
-
错误:二进制操作数无效
标签: iphone objective-c arrays comparison int