GCD:如何更改定时器的启动间隔

无论如何,这可能听起来是一个新手问题,我对GCD很陌生

我有以下代码:

int interval = 2; int leeway = 0; dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); dispatch_source_t timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue); if (timer) { dispatch_source_set_timer(timer, dispatch_walltime(DISPATCH_TIME_NOW, NSEC_PER_SEC * interval), interval * NSEC_PER_SEC, leeway); dispatch_source_set_event_handler(timer, ^{ [self someMethod]; }); dispatch_resume(timer); } 

哪些方法是:

 - (void)someMethod { NSLog(@"Thread 1"); } 

如何在某些方法中更改timer的启动间隔属性?

得到了我自己的答案,调用dispatch_source_set_timer与新的区间值就足够了