99热99这里只有精品6国产,亚洲中文字幕在线天天更新,在线观看亚洲精品国产福利片 ,久久久久综合网

歡迎加入QQ討論群258996829

Swift 后臺(tái)執(zhí)行代碼封裝庫(kù) Async

發(fā)布時(shí)間:2016-06-22 23:27  回復(fù):0  查看:4932  感興趣:11  贊:0   最后回復(fù):2016-06-22 23:27  

Swift 后臺(tái)執(zhí)行代碼封裝庫(kù) Async。

Swift 中寫(xiě)GDC(Grand Central Dispatch)類(lèi)似這樣的:

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), {
    print("This is run on the background queue")

    dispatch_async(dispatch_get_main_queue(), {
        print("This is run on the main queue, after the previous block")
    })
})
使用  Async 的要簡(jiǎn)潔的多:

Async.background {
    print("This is run on the background queue")
}.main {
    print("This is run on the main queue, after the previous block")
}
Async支持的方法:

Async.main {}
Async.userInteractive {}
Async.userInitiated {}
Async.utility {}
Async.background {}
支持多個(gè)代碼塊:

Async.userInitiated {
    // 1
}.main {
    // 2
}.background {
    // 3
}.main {
    // 4
}


相關(guān)開(kāi)源代碼

您還未登錄,請(qǐng)先登錄

熱門(mén)帖子

最新帖子

?