Last active
February 21, 2020 14:11
-
-
Save boazFrenkel/c3629ce02a53adef0b6d127de665ad6f to your computer and use it in GitHub Desktop.
Alamofire 4 get the response on a specific queue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let queue = DispatchQueue(label: "com.response-queue", qos: .utility, attributes: [.concurrent]) | |
Alamofire.request("Some URL", parameters: ["Some": "Param"]) | |
.response( | |
queue: queue, | |
responseSerializer: DataRequest.jsonResponseSerializer(), | |
completionHandler: { response in | |
/* | |
You are now running on the queue you created. So you | |
can parse the response to model objects or do any | |
other handling if necessary. | |
*/ | |
//Then you can return to the main thread | |
DispatchQueue.main.async { | |
} | |
} | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment