GCDTimer
GCDTimer copied to clipboard
dispatch after misuse
trafficstars
dispatch_source_set_timer(timer,
dispatch_time(DISPATCH_TIME_NOW, 0), --------> Configure here the start time, put the interval with dispatch_time or dispatch_walltime
interval * NSEC_PER_SEC,
0);
....
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, interval * NSEC_PER_SEC), queue, ^{
dispatch_resume(timer);
}); -----> just resume normally now, no more dispathc_after
dispatch_source_set_timer(timer, dispatch_time(DISPATCH_TIME_NOW, 0), --------> Configure here the start time, put the interval with dispatch_time or dispatch_walltime interval * NSEC_PER_SEC, 0); .... dispatch_after(dispatch_time(DISPATCH_TIME_NOW, interval * NSEC_PER_SEC), queue, ^{ dispatch_resume(timer); }); -----> just resume normally now, no more dispathc_after
no no no
The first run will also be after 1 second
effect equals NSTimer
NSTimer scheduledTimerWithTimeInterval:1 repeats:YES block:^...