Created
July 31, 2012 00:11
-
-
Save leepfrog/3212220 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
| _clockFormat = [[NSDateFormatter alloc] init]; | |
| [_clockFormat setTimeStyle:NSDateFormatterLongStyle]; | |
| [_clockFormat setLocale:[NSLocale systemLocale]]; | |
| dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); | |
| _clockTimer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue); | |
| dispatch_source_set_timer(_clockTimer, DISPATCH_TIME_NOW, kClockUpdateInterval * NSEC_PER_SEC, 0); | |
| dispatch_source_set_event_handler(_clockTimer, ^{ | |
| self.clock.text = [_clockFormat stringFromDate:[NSDate date]]; | |
| NSLog(@"%@",[_clockFormat stringFromDate:[NSDate date]]); | |
| }); | |
| // now that our timer is all set to go, start it | |
| dispatch_resume(_clockTimer); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment