我有很多請求女巫我想不斷地調用一個沒有嵌套意大利麪代碼的請求。Alamofire一個接一個的請求數
我有一個串行調度隊列
let queue = dispatch_queue_create("label", DISPATCH_QUEUE_SERIAL)
Alamofire.request(Router.Countries).responseString { (response:Response<String, NSError>) in
print(1)
}
Alamofire.request(Router.Countries).responseString { (response:Response<String, NSError>) in
print(2)
}
Alamofire.request(Router.Countries).responseString { (response:Response<String, NSError>) in
print(3)
}
試過了,不過遺憾的是不工作。其輸出可以是1,3,2或3,1,2或其他任何組合。
什麼是最好的方法來獲得輸出1,2,3一個接一個。
你有幾次嘗試,或者你已經知道你會有多少次要求? – Miknash
我知道有多少病態,但當然這將是更好的動態 – Eike
你試過使用'dispatch_semaphore'?我沒有時間回答一個很好的答案,但你可以在這裏找到很多例子。SO –