Skip to content

Instantly share code, notes, and snippets.

Created October 21, 2016 08:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/694061d524db51d38ef7711531da7d72 to your computer and use it in GitHub Desktop.
Save anonymous/694061d524db51d38ef7711531da7d72 to your computer and use it in GitHub Desktop.
#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