星空网 > 软件开发 > 操作系统

Swift 延迟运行

//// DelayRun.swift// //// Created by XuQing on 16/7/1.// Copyright © 2016年 xuqing. All rights reserved.//import Foundationtypealias Task = (cancel : Bool) -> ()func DelayRun(time:NSTimeInterval, task:()->()) -> Task? {    func dispatch_later(block:()->()) {    dispatch_after(      dispatch_time(        DISPATCH_TIME_NOW,        Int64(time * Double(NSEC_PER_SEC))),      dispatch_get_main_queue(),      block)  }    var closure: dispatch_block_t? = task  var result: Task?    let delayedClosure: Task = {    cancel in    if let internalClosure = closure {      if (cancel == false) {        dispatch_async(dispatch_get_main_queue(), internalClosure);      }    }    closure = nil    result = nil  }    result = delayedClosure    dispatch_later {    if let delayedClosure = result {      delayedClosure(cancel: false)    }  }    return result;}func cancel(task:Task?) {  task?(cancel: true)}

 




原标题:Swift 延迟运行

关键词:

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

做好亚马逊review后,后期我们还需要做什么?:https://www.ikjzd.com/articles/111317
Facebook广告能带来哪些收益?有哪些因素我们必须要注意?:https://www.ikjzd.com/articles/111318
亚马逊库存尽快能完成吗?接近年底我们还需要做些什么?:https://www.ikjzd.com/articles/111319
YouTube和Instagram,哪个社媒适合做网红营销?:https://www.ikjzd.com/articles/111320
是爆款还是“暴雷”?黑五备货避雷指南请收好!:https://www.ikjzd.com/articles/111321
这样的亚马逊运营,你不要当!:https://www.ikjzd.com/articles/111322
在英国有分公司的中国公司:https://www.xlkjsw.com/tag/30029.html
英国成立:https://www.xlkjsw.com/tag/30031.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流