In a certain view I wish to have a certain method fired when the firing timing is based on an array of NSTimeIntervals (which I keep in as NSArray holding double values).
So I have a method that does the relevant action according to the relevant timing, and within this method I call the same method (recursively) to be fired again in the next scheduled time:
-(void) actionMethod:(int)someDataINeed {
//do something and then...
if (someDataINeed == someDefinitionIHaveToBreakTheLoop) {
return;
}
double nextFire = [self aMethodThatCalculatesTheNextFiringTime];
NSNumber * nextDataINeed = [NSNumber numberWithInt:someDataINeed+1];
NSTimer * aTimer = [NSTimer scheduledTimerWithTimeInterval:nextFire
target:self
selector:@selector(actionMethod:)
userInfo:nextDataINeed
repeats:NO];
}
Well... it doesn't work (if it did, I guess I wouldn't ask about it...). When I NSLog it, it seems like the time is not running at all and that the timer is called in some sort of loop and not "being fired" according to the timing I had defined. The nextFire double data is correct (according to my definitions).
If I have it wrong, I would appreciate if someone can direct me to how this type of action should be performed.
If I got it right, but simply write it wrong, an eye that catches my "bug" would be appreciated as well...