継続的に実行される関数内に NSMutableArray を作成し、その値を一度だけ初期化して、関数が繰り返し呼び出されるときに値を初期化し続けないように (変更された値を置き換えないように) しようとしています。私の問題は、if ステートメントで値を初期化しようとすると、配列の値が変更されないことです。「値は 1」を出力すると予想しているときに、「値は 0」を出力し続けます。
関連するコードは次のとおりです。
@property (nonatomic, strong) NSMutableArray * shapeMarked;
@synthesize shapeMarked;
//locationManager is the function that's continuously called
-(void) locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
//event count is an integer that continuously increases by one each time the
//parent function is called, this if statement is used so that it only happens
//once
if(eventcount == 1){
for (int i = 0; i < 5; i++){
BOOL b = YES;
[shapeMarked addObject:[NSNumber numberWithBool:b]];
NSLog(@"value is %d", [[shapeMarked objectAtIndex:i] boolValue] );
}
}
}