-1
我将值存储在NSMutableArray
中,但是当我尝试检索它时,它找不到它。无法存储和检索NSMutable数组中的值
我的目标是寻找灯塔主要ID。如果找到新的信标主标识,我将它保存在数组中。所以下一次当我读取Beacon主编号时,如果它已经存在于数组中,我不会使用它。
for (int i=0; i<numberOfBeacondsInRange; i++)
{
NSLog(@"Processing current beacon: %d of %d", i, numberOfBeacondsInRange-1);
ESTBeacon *currentBeacon = [self.beaconsArray objectAtIndex:i];
// not able to retrive values from the array to compare
BOOL isPresent=NO;
for (int j=0; j<100; j++)
{
if ([visitedBeaconsArrayMajor objectAtIndex:j] == currentBeacon.major)
{
NSLog(@"Already seen");
isPresent=YES;
}
}
if (isPresent==NO)
{
[visitedBeaconsArrayMajor addObject:currentBeacon.major];
NSLog(@"Add major:%@",currentBeacon.major);
}
}
你分配了/ init'visitedBeaconsArrayMajor'吗? – rmaddy
首先检查NSLog(@“%@”,visitedBeaconsArrayMajor);如果它为null,那么你应该分配一个数组 –