swift- 延时执行

swift代码

let delayTime = dispatch_time(DISPATCH_TIME_NOW, Int64(1 * Double(NSEC_PER_SEC)))
        let queue : dispatch_queue_t = dispatch_get_main_queue()
        dispatch_after(delayTime, queue) { 
            //execute code...
        }

OC版

 dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        
     //execute code...
    });

你可能感兴趣的:(swift- 延时执行)