Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/111.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 无法从NSMutable数组中存储和检索值_Ios_Objective C_Arrays_Nsmutablearray_Estimote - Fatal编程技术网

Ios 无法从NSMutable数组中存储和检索值

Ios 无法从NSMutable数组中存储和检索值,ios,objective-c,arrays,nsmutablearray,estimote,Ios,Objective C,Arrays,Nsmutablearray,Estimote,我正在NSMutableArray中存储一个值…但是当我尝试检索它时,它没有找到它 我的目标是查找信标主id。如果找到新的信标主id,我将其保存在数组中。所以下次当我读取信标主id时,如果它已经存在于数组中,我不会使用它 for (int i=0; i<numberOfBeacondsInRange; i++) { NSLog(@"Processing current beacon: %d of %d", i, numberOfBeacondsInRange-1);

我正在NSMutableArray中存储一个值…但是当我尝试检索它时,它没有找到它

我的目标是查找信标主id。如果找到新的信标主id,我将其保存在数组中。所以下次当我读取信标主id时,如果它已经存在于数组中,我不会使用它

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);
     }
}

通常情况下,如果在NSMutableArray属性投入使用之前没有初始化它,则会发生这种情况,如VisitedBeaconArrayMajor=[[NSMutableArray alloc]init];结果是零

您是否分配/初始化visitedBeaconsArrayMajor?首先检查NSLog@%@,visitedBeaconsArrayMajor;如果为空,则应分配一个数组