Last active
April 8, 2023 23:26
-
-
Save LukeSmith16/91830f1a0b18b6a144887ca06815bbcc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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