I had a similar problem:
in the main user interface thread, the call:
dispatch_semaphore_wait(loginDoneSemaphore, DISPATCH_TIME_FOREVER)
and call http using Alamofire, also use your httpRequest.responseJSON
- > - responseJSON
- > , DISPATCH_TIME_FOREVER
- > , : Alamofire responseJSON, , /,
- > Alamofire, , DISPATCH_TIME_FOREVER
- > AlamofireJSON, ,
- > : Alamofire http- :
let BackgroundThread:dispatch_queue_t = dispatch_get_global_queue(QOS_CLASS_BACKGROUND, 0)
func dispatchBackground_async(thingsTodo:()->()) {
dispatch_async(BackgroundThread, thingsTodo)
}
dispatchBackground_async({
httpRequest.responseJSON(queue: BackgroundThread, completionHandler: { response in
gLog.debug("request=\(response.request), response=\(response.response), statusCode=\(response.response?.statusCode), result=\(response.result)")
// [Debug] [com.apple.root.background-qos] [CrifanLibHttp.swift:21]
})
.
- > , : AlamofireJSON, .