URLSessionEventHub
public final class URLSessionEventHub : NSObject
extension URLSessionEventHub: URLSessionTaskDelegate
extension URLSessionEventHub: URLSessionDataDelegate
extension URLSessionEventHub: URLSessionDownloadDelegate
Forwards callbacks from a URLSession to objects implementing URLSessionObserver. Assigns a single observer per URLSessionTask and that observer
receives all callbacks associated with that task.
-
Undocumented
Declaration
Swift
override public init() -
Assigns an observer for a specific
URLSessionTask. This unassigns the previous observer to the provided task. The new observer will receive all callbacks fortaskuntil it is explicitly removed from this instance, or, iftaskcompletes. A task is considered completed whenurlSession(:task:didCompleteWithError:)is invoked in which case the hub will forward this last call to its observer and then remove it.
Declaration
Swift
public func setObserver(_ observer: URLSessionObserver, for task: URLSessionTask)Parameters
observerAn object that will receive all callbacks for
task.taskThe task to associate with
observer. -
Removes the observer for a specific
URLSessionTask, if one exists.Declaration
Swift
public func removeObserver(for task: URLSessionTask)Parameters
taskThe task to stop observing.
-
Undocumented
Declaration
Swift
@objc public func urlSession(_ session: URLSession, task: URLSessionTask, didSendBodyData bytesSent: Int64, totalBytesSent: Int64, totalBytesExpectedToSend: Int64) -
Undocumented
Declaration
Swift
@objc public func urlSession(_ session: URLSession, task: URLSessionTask, didCompleteWithError error: Error?) -
Undocumented
Declaration
Swift
@objc public func urlSession(_ session: URLSession, dataTask: URLSessionDataTask, didReceive data: Data) -
Undocumented
Declaration
Swift
@objc public func urlSession(_ session: URLSession, downloadTask: URLSessionDownloadTask, didFinishDownloadingTo location: URL) -
Undocumented
Declaration
Swift
@objc public func urlSession(_ session: URLSession, downloadTask: URLSessionDownloadTask, didWriteData bytesWritten: Int64, totalBytesWritten: Int64, totalBytesExpectedToWrite: Int64)
View on GitHub
URLSessionEventHub Class Reference