I want to add an NSObject to an NSMutableArray inside of a a block. In the code below, the NSLog line works fine and returns the number I expect. However, when I try to add that result to an NSArray, the array is always empty when I go to access it later.
CMStepQueryHandler stepQueryHandler = ^(NSInteger numberOfSteps,
NSError *error) {
NSLog(@"CMStepQueryHandler: Steps on day: %i", (int)numberOfSteps);
[stepsPerDay addObject:[NSNumber numberWithInt:numberOfSteps]];
};
How can I add an object to an NSMutableArray (in this case stepsPerDay) from inside of a block so that I can access it later?