This might be a stupid question, but I have some issues changing my code to avoid some deprecated code in iOS9.
I have created an app that logs in to a webpage. The webpage uses a username and a password which forwards to a page where a token has to be entered.
I have been able to login to that webpage by using three urls that have been loaded synchronously in a for-loop. Here is a quick example of the process:
let urls = ["www.testpage.com", "www.testpage.com/username=erik&password=123", "www.testpage.com/token=123456"]
for (index, url) in urls.enumerate() {
self.urlRequest = NSMutableURLRequest(URL: urlObject.baseUrl, cachePolicy: NSURLRequestCachePolicy.ReloadIgnoringLocalAndRemoteCacheData, timeoutInterval: 30.0)
NSURLConnection.sendSynchronousRequest(self.urlRequest, returningResponse: &response)
if index == 2 {
print("Login successful")
}
}
This has worked just fine as the synchronous request has triggered on url at a time in correct sequence.
I am now having trouble achieving the same thing with dataTaskWithRequest as the last url sometimes triggeres before the first one has finished.
Do you have any recommendations of how to do this correctly?
Appreciate any help!
Regards, Erik