Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - (IBAction)StartStop:(id)sender {
- if (startbutton == NO){
- [StartButton setTitle:@"Stop" forState:UIControlStateNormal];
- startbutton= YES;
- rundenzaehler = 0;
- RundenText = @"";
- [self Start];
- startDate = [[NSDate date] init];
- }else {
- [StartButton setTitle:@"Start" forState:UIControlStateNormal];
- startbutton= NO;
- [stopwatchTimer invalidate];
- stopwatchTimer = nil;
- startDate = nil;
- }
- }
- - (void)Start{
- [RundenTextView setText:@""];
- stopwatchTimer = [NSTimer scheduledTimerWithTimeInterval: 0.001 target:self selector:@selector(tick:) userInfo:nil repeats:YES];
- [stopwatchTimer fire];
- }
- - (void)tick:(NSTimer *)theTimer
- {
- //NSTimeInterval interval = -[startDate timeIntervalSinceNow];
- NSTimeInterval interval =[startDate timeIntervalSinceNow] * -1000.0;
- int millis = ((int)interval)% 1000;
- int seconds = (((int)interval)/1000) %60;
- int minutes = (((int) (interval/1000) - seconds) / 60) % 60;
- int hours = (((int) interval/1000) - seconds - 60 * minutes) % 3600;
- ZeitString = [NSString stringWithFormat:@"%.2d:%.2d:%.2d:%.3d", hours,
- minutes, seconds, millis];
- [elapsedTime setText:ZeitString];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement