Answers for "do something when your HTTP response finishes. swift"

0

do something when your HTTP response finishes. swift

import Foundation

<...>

var done = false

let task = session.dataTask(with: request as URLRequest) {
    (data, response, error) in

    <...>
    done = true
}

task.resume()

repeat {
    RunLoop.current.run(until: Date(timeIntervalSinceNow: 0.1))
} while !done

//credits https://stackoverflow.com/users/539599/raphael
Posted by: Guest on February-24-2022

Code answers related to "do something when your HTTP response finishes. swift"

Code answers related to "Swift"

Browse Popular Code Answers by Language