主线程中延迟的调用方法

你好,我需要帮助我..请帮助我。 下面是我在我的应用程序中运行的每个.30delay的线程。

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ notification = [[NSNotificationCenter alloc] init]; notificationTimer = [NSTimer scheduledTimerWithTimeInterval:.30 target:self selector:@selector(notificationTimerFired:) userInfo:nil repeats:YES]; [[NSRunLoop currentRunLoop] run]; }); 

我想要的是在方法“notificationTimerFired”我打电话多一个方法,这是被称为说5秒间隔..我怎么做..我试图添加以下代码,但在第一次它要求指定的延迟但后来它不断调用dispatch_async方法被调用。 请回复我,我非常需要

  [NSTimer scheduledTimerWithTimeInterval:.30 target:self selector:@selector(notificationTimerFired:) userInfo:nil repeats:YES]; 

伙计们,我find了解决问题的办法,结果如下

 //run only once for specified delay static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ notification = [[NSNotificationCenter alloc] init]; notificationTimer = [NSTimer scheduledTimerWithTimeInterval:frequency*60 target:self selector:@selector(repeateThreadForSpecificInterval:) userInfo:nil repeats:YES]; // Do any other initialisation stuff here }); 

dispatch_once是我正在寻找的关键。 任何方式感谢您的答复..