Created
May 27, 2011 04:01
-
-
Save sbrocket/994620 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - (IBAction)buttonPressed:(id)sender { | |
| if (timer == nil) { | |
| seconds = 30; | |
| timer = [[NSTimer scheduledTimerWithTimeInterval:1.0 | |
| target:self | |
| selector:@selector(updateCounter:) | |
| userInfo:nil | |
| repeats:YES] retain]; | |
| } | |
| } | |
| - (void)updateCounter:(NSTimer *)theTimer { | |
| if (seconds > 0) { | |
| --seconds; | |
| } else { | |
| seconds = 30; | |
| [timer invalidate]; | |
| [timer release]; | |
| timer = nil; | |
| } | |
| self.myCounterLabel.text = [NSString stringWithFormat:@"%d", seconds]; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment