You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Start with a simple GET request in Postman, and then ask Postman to generate the code for the corresponding Swift equivalent using URLSession. You'll get something with this form:
var semaphore = DispatchSemaphore (value: 0)
var request = //
let task = URLSession.shared.dataTask(with: request) { data, response, error in
guard let data = data else {
print(String(describing: error))
semaphore.signal()
return
}
print(String(data: data, encoding: .utf8)!)
semaphore.signal()
}
task.resume()
semaphore.wait()
This is wrong. One should basically never use semaphores, and certainly there is no need for them here. The correct answer to the question that we're asking Postman, how to perform this same request in Swift, is to take all of that code and delete every line containing the word "semaphore". So, since everyone is always going to have to do that, why include those lines to begin with?
The text was updated successfully, but these errors were encountered:
@mattneub Thanks again for the input!
We've raised a PR regarding the removal of the unnecessary semaphores and it's currently under review. It should be live with the next release of the module and you should be able to observe the change in the next release of Postman app. 👍 Stay tuned!
Start with a simple GET request in Postman, and then ask Postman to generate the code for the corresponding Swift equivalent using URLSession. You'll get something with this form:
This is wrong. One should basically never use semaphores, and certainly there is no need for them here. The correct answer to the question that we're asking Postman, how to perform this same request in Swift, is to take all of that code and delete every line containing the word "semaphore". So, since everyone is always going to have to do that, why include those lines to begin with?
The text was updated successfully, but these errors were encountered: