Skip to content

Instantly share code, notes, and snippets.

@LukeSmith16
Last active April 8, 2023 23:26
Show Gist options
  • Save LukeSmith16/91830f1a0b18b6a144887ca06815bbcc to your computer and use it in GitHub Desktop.
Save LukeSmith16/91830f1a0b18b6a144887ca06815bbcc to your computer and use it in GitHub Desktop.
func expensiveLongRunningDataTask() {
let config = URLSessionConfiguration.default
// Be low data mode compliant
config.allowsConstrainedNetworkAccess = false
// Automatically retrigger the request when we are on Wi-Fi.
config.waitsForConnectivity = true
let request = URLRequest(url: myURL)
let session = URLSession(configuration: config, delegate: nil, delegateQueue: nil)
session.dataTask(with: request) { data, response, error in
// Logic...
}.resume()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment