diff options
| author | mo khan <mo@mokhan.ca> | 2013-06-12 21:17:21 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2013-06-12 21:17:21 -0600 |
| commit | 770e5967e8da36e90b68745c6ca51a02924e22e5 (patch) | |
| tree | ec29cb4381f258fdfa45ef752e80763d24f56423 | |
| parent | 1ab00b9d126d9c498a6585d73c5d6dd185b06495 (diff) | |
stop timer when the ball is pressed
| -rw-r--r-- | Wobble.xcodeproj/project.xcworkspace/xcuserdata/mo.xcuserdatad/UserInterfaceState.xcuserstate | bin | 16624 -> 16635 bytes | |||
| -rw-r--r-- | Wobble/ViewController.m | 10 |
2 files changed, 8 insertions, 2 deletions
diff --git a/Wobble.xcodeproj/project.xcworkspace/xcuserdata/mo.xcuserdatad/UserInterfaceState.xcuserstate b/Wobble.xcodeproj/project.xcworkspace/xcuserdata/mo.xcuserdatad/UserInterfaceState.xcuserstate Binary files differindex 10c381b..95b319f 100644 --- a/Wobble.xcodeproj/project.xcworkspace/xcuserdata/mo.xcuserdatad/UserInterfaceState.xcuserstate +++ b/Wobble.xcodeproj/project.xcworkspace/xcuserdata/mo.xcuserdatad/UserInterfaceState.xcuserstate diff --git a/Wobble/ViewController.m b/Wobble/ViewController.m index ab65104..0b18b8e 100644 --- a/Wobble/ViewController.m +++ b/Wobble/ViewController.m @@ -3,7 +3,7 @@ @interface ViewController () @property int score; - @property (strong, nonatomic) NSTimer * myTimer; + @property (strong, nonatomic) NSTimer * timer; @end @implementation ViewController @@ -36,16 +36,22 @@ - (void)startTimer { - self.myTimer = [NSTimer scheduledTimerWithTimeInterval:5 target:self selector:@selector(moveBallToRandomLocation) userInfo:nil repeats:NO]; + self.timer = [NSTimer scheduledTimerWithTimeInterval:5 target:self selector:@selector(moveBallToRandomLocation) userInfo:nil repeats:NO]; } -(void)onTouch:(UIGestureRecognizer *)sender { [self moveBallToRandomLocation]; + [self stopTimer]; self.score += 2; self.scoreLabel.text = [NSString stringWithFormat:@"%d", self.score]; } +-(void)stopTimer +{ + [self.timer invalidate]; +} + - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; |
