Skip to content

Instantly share code, notes, and snippets.

@boazFrenkel
Last active February 21, 2020 14:11
Show Gist options
  • Save boazFrenkel/c3629ce02a53adef0b6d127de665ad6f to your computer and use it in GitHub Desktop.
Save boazFrenkel/c3629ce02a53adef0b6d127de665ad6f to your computer and use it in GitHub Desktop.
Alamofire 4 get the response on a specific queue
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