so I've fixed the issue by putting all of the code that loads the username and password into the function that runs when the internet is connected, so the final code looks something like this:
monitor.pathUpdateHandler = { path in
if path.status == .satisfied {
let usernamestored = defaults!.string(forKey: "username")!
...
let task = URLSession.shared.dataTask(with: request) { (data, response, error) in {...}
task.resume()
}
}
Topic:
Programming Languages
SubTopic:
Swift
Tags: