Ios 使用NSTimer在存储在数组中的时间触发方法

Ios 使用NSTimer在存储在数组中的时间触发方法,ios,nsarray,nstimer,nstimeinterval,Ios,Nsarray,Nstimer,Nstimeinterval,我有一个存储时间的数组。我希望NStimer在存储在该数组中的时间触发。例如,在数组a[]中,我有2秒、5秒和10秒,希望NSTimer在这些时间触发一个方法。我确实有另一个NSTimer,它每秒都在更新时间实例变量 一个简单的解决方案是在数组中循环并使用GCD安排方法调用 for (NSNumber *time in array) { NSTimeInterval delay = [time doubleValue]; dispatch_after(dispatch_time(

我有一个存储时间的数组。我希望NStimer在存储在该数组中的时间触发。例如,在数组a[]中,我有2秒、5秒和10秒,希望NSTimer在这些时间触发一个方法。我确实有另一个NSTimer,它每秒都在更新时间实例变量

一个简单的解决方案是在数组中循环并使用GCD安排方法调用

for (NSNumber *time in array) {
    NSTimeInterval delay = [time doubleValue];
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delay * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
            <#code to be executed after a specified delay#>
        });
}
for(NSNumber*数组中的时间){
NSTimeInterval delay=[时间加倍值];
在(调度时间(现在调度时间,(int64_t)(延迟*NSEC_/u秒))之后调度,调度获取主队列()^{
});
}

如果我的时间以毫秒为单位,如果我必须暂停数组,并且必须从数组中的不同点读取数据,我该怎么办。因为for循环不会停止并一直执行到结束点