Created
September 3, 2019 04:41
-
-
Save mjhassan/1b946a00168ac4c6dbd899826e518c89 to your computer and use it in GitHub Desktop.
Simple service class template for URLCache example
This file contains hidden or 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
| class APIService: ServiceProtocol { | |
| func get( url: URL, callback: @escaping (_ data: Data?, _ error: Error?) -> Void ) { | |
| let request = URLRequest(url: url, cachePolicy: .returnCacheDataElseLoad, timeoutInterval: 30) | |
| URLSession.shared.dataTask(with: request) { (data, _, error) in | |
| callback(data, error) | |
| }.resume() | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment