美文网首页
swift- 延时执行

swift- 延时执行

作者: 夏天爱大树 | 来源:发表于2016-10-24 16:49 被阅读413次

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- 延时执行

      本文链接:https://www.haomeiwen.com/subject/wnuluttx.html