Created
October 21, 2016 08:57
-
-
Save anonymous/694061d524db51d38ef7711531da7d72 to your computer and use it in GitHub Desktop.
This file contains 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
#import "ViewController.h" | |
@interface ViewController (){ | |
IBOutlet UILabel *lblTime; | |
NSTimer *timer; | |
NSUInteger timerCount; | |
} | |
@end | |
@implementation ViewController | |
- (void)viewDidLoad { | |
[super viewDidLoad]; | |
timerCount = 0; | |
lblTime.text = @"0"; | |
} | |
-(void)count{ | |
timerCount++; | |
lblTime.text = [NSString stringWithFormat:@"%lu", (unsigned long)timerCount]; | |
} | |
- (IBAction)btnStart:(id)sender { | |
timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(count) userInfo:nil repeats:YES]; | |
} | |
- (IBAction)btnStop:(id)sender { | |
[timer invalidate]; | |
timer = nil; | |
} | |
- (void)didReceiveMemoryWarning { | |
[super didReceiveMemoryWarning]; | |
// Dispose of any resources that can be recreated. | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment