Are you wanting to move the image every 2 seconds, or make it move increasingly faster? It won't move faster, if you only move it every 2 seconds.
You can read the docs for NSTimer, but to take some of the headache out of it, here's some examples of how to use NSTimer for this.
If you're wanting to move it every two seconds, you can do the following.
- (void) startTimer {
[_myTimer invalidate];
_myTimer = nil;
_myTimer = [NSTimer timerWithTimeInterval:2. target:self selector:@selector(respondToTimer:) userInfo:nil repeats:YES];
[[NSRunLoop currentRunLoop] addTimer:_myTimer forMode:NSRunLoopCommonModes];
}
- (void)respondToTimer:(NSTimer*)timer {
//Code to move your UIImageView
}
If you're wanting to move it increasingly faster, you can do the following.
- (void) startTimer {
[_myTimer invalidate];
_myTimer = nil;
_myTimer = [NSTimer timerWithTimeInterval:_timeInterval target:self selector:@selector(respondToTimer:) userInfo:nil repeats:NO];
[[NSRunLoop currentRunLoop] addTimer:_myTimer forMode:NSRunLoopCommonModes];
}
- (void)respondToTimer:(NSTimer*)timer {
//Code to move your UIImageView
_numberOfMoves++;
if (_numberOfMoves < MAX_MOVES) {
_timeInterval /= 2;
[self startTimer];
}
}