After this discussion, I ran into a bad access problem;
The cycle has several steps: a, b, c, ... x, y, z:
-(void)cycle:(float)delta{ [self stepA] [self stepB]
At some point, step x performs the following actions:
Later, step z should handle all the βdelayedβ calls:
for (int i = 0; i < [IRQ count]; i++){ void (^delayedCall)(void) = [IRQ objectAtIndex:i]; delayedCall(); } [IRQ removeAllObjects];
Result: EXEC_BAD_ACCESS
Now, if in step x a simple line is added without an object reference, as shown below, step Z works fine:
[IRQ addObject:^{ NSLog(@"hello!"); } ];
The last observation, if the same step adds blocks to the queue AND iterates in turn to execute the blocks, then no problems arise. How an object reference gets "lost" as a step: does the method remain?
I do not really understand in this area and need additional help!
edit: James, just tried the following to avoid this cyle link:
NSString *userName = @"James"; [IRQ addObject:^{ NSLog(@"hello %@", userName); } ];
and it also happens. How does your decision apply to this?
Thanks in advance!