UrlSessionManager
class UrlSessionManager : IUrlSessionManager
Manages obtaining data object from url using URLSession object that is passed to initializer. If it is needed, this approach gives us the ability to change the way the data is obtained by passing the object inherited from URLSession in initializer.
-
object that handles data obtaining
Declaration
Swift
private let urlSession: URLSession
-
Initialises with URLSession
Declaration
Swift
init(_ urlSession: URLSession = URLSession.shared)
Parameters
urlSession
The object which handles data obtaining.
-
Performs obtaining data from specified URL.
Declaration
Swift
func getDataFromUrl(_ url: URL) -> (Data?, NSError?)
Parameters
url
The object from which to obtain data.
Return Value
Data object and nil as error on success or nil as data and error on failure.