I want to send multiple HTTP requests (one after the other) in Swift using NSUrlSession
, I am trying to login to a web page so I need to send a GET request and use the cookie for the following POST request and then use that authentication cookie to get the data I want from the site (a simple string from the response).
So I use this function call to send the request:
var task = session.dataTaskWithRequest(request, completionHandler: { (data, response, error) -> Void in
//Do stuff with response
})
task.resume()
But I don't want to put tasks inside tasks clousure because what if I have 100 requests? I feel like there has to be another way but I could not find any example that uses more then a single request.