***Timer Delay:
double delayInSeconds = 1.2;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
NSLog(@"Do some work");
});
***Timer Repeat:
- (void)viewDidAppear:(BOOL)animated {
float delayTime = 1.0f;
if (_timerUpdate == nil) {
_timerUpdate = [NSTimer scheduledTimerWithTimeInterval:delayTime target:self selector:@selector(onTickUpdateIcon:) userInfo:nil repeats:YES];
}
[_timerUpdate fire];
}
- (void)onTickUpdateIcon:(NSTimer *)timer {
// do something...
}
- (void)viewDidDisappear:(BOOL)animated {
[_timerUpdate invalidate];
_timerUpdate = nil;
}
Không có nhận xét nào:
Đăng nhận xét