0
在我的簡單代碼中,如果條件x == 2並且轉到主隊列,我希望在隊列全局中斷進程。dispatch_async中的break隊列處理iOS Swift 2.0
如何繼續?
達里奧·巴索卡多佐
var x = 1
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW,0)) {
x++
if x == 2 {
break // error in this part or
return // does not work well
}
// more codes...
dispatch_async(dispatch_get_main_queue()) { () -> Void in
// execute the main code
// with break or not
if x == 2 {
// verified that break
}
// next codes
}
}