I have question how to stop the timer. I don’t really understand how it works much though. Please help me.
I have an IQ app, let’s say there are 10 questions, each question not to be answered in 4 seconds.
- (void) requestForItem
{
TrainEnglishAppDelegate *delegate = (TrainEnglishAppDelegate*)[UIApplication sharedApplication].delegate;
NSDictionary *item = [delegate.allQuestions objectAtIndex:z];
questionLabel.text = [item objectForKey:kQuestion];
questionNumber.text = [NSString stringWithFormat:@"Question %d/%d",no,totalNo];
NSArray *answers = [item objectForKey:kAnswers];
aLabel.text = [answers objectAtIndex:0];
bLabel.text = [answers objectAtIndex:1];
cLabel.text = [answers objectAtIndex:2];
[NSTimer scheduledTimerWithTimeInterval:4.0 target:self selector:@selector(pressToNextQuestion:) userInfo:nil repeats:NO];
}
This works until the skip question button appears. User press next button, to skip question, but the timer in that question is still timing. Then when I am in the other question, my time is reduced. How can I reset the timer when I press skip? please help me. Thanks a lot
Timer invalidation can be done in the following way
So take your timer in a variable and to stop it, just use the second line wherever you want to stop it.