I would move the mathTimer into your class header: inside your . F file: @interface YourClassNAme : YourSuperClassesName { NSTimer *mathTimer } @property (nonatomic, retain) NSTimer *mathTimer; //inside your . M: @implementation YourClassNAme @synthesize mathTimer; -(void) dealloc { //Nil out release the property self.
MathTimer = nil; super dealloc; } And change your method to access to timer through the property: (IBAction)doCalculation:(id)sender { NSInteger numAnswer = answer. Text intValue; if ( numAnswer == first + second) { numAnswered++; NSString *numberAnsweredCorrectly = NSString alloc initWithFormat:@"%d", numAnswered; numCorrectlyAnswered. Text = numberAnsweredCorrectly; answer.
Text = @""; self. MathTimer invalidate; //invalidate the old timer if it exists self. MathTimer = NSTimer scheduledTimerWithTimeInterval:5.0 target:self selector:@selector(onTimer) userInfo:nil repeats:YES; //Set the variables to two HUGE numbers, so they can't keep plugging in the same answer first = arc4random() % 10; second = arc4random() % 10; NSString *firstString = NSString alloc initWithFormat:@"%d", first; NSString *secondString = NSString alloc initWithFormat:@"%d", second; firstNumber.
Text = firstString; secondNumber. Text = secondString; }.
I would move the mathTimer into your class header: //inside your . F file: @interface YourClassNAme : YourSuperClassesName { NSTimer *mathTimer } @property (nonatomic, retain) NSTimer *mathTimer; //inside your . M: @implementation YourClassNAme @synthesize mathTimer; -(void) dealloc { //Nil out release the property self.
MathTimer = nil; super dealloc; } And change your method to access to timer through the property: - (IBAction)doCalculation:(id)sender { NSInteger numAnswer = answer. Text intValue; if ( numAnswer == first + second) { numAnswered++; NSString *numberAnsweredCorrectly = NSString alloc initWithFormat:@"%d", numAnswered; numCorrectlyAnswered. Text = numberAnsweredCorrectly; answer.
Text = @""; self. MathTimer invalidate; //invalidate the old timer if it exists self. MathTimer = NSTimer scheduledTimerWithTimeInterval:5.0 target:self selector:@selector(onTimer) userInfo:nil repeats:YES; //Set the variables to two HUGE numbers, so they can't keep plugging in the same answer first = arc4random() % 10; second = arc4random() % 10; NSString *firstString = NSString alloc initWithFormat:@"%d", first; NSString *secondString = NSString alloc initWithFormat:@"%d", second; firstNumber.
Text = firstString; secondNumber. Text = secondString; }.
If you you are making a game, you should use a game loop where the game is updated in that loop. Then you can check the results after the time is up. You will only have 1 continuos timer to deal with.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.