NetworkActivityIndicatorObserver
open class NetworkActivityIndicatorObserver
extension NetworkActivityIndicatorObserver: SAPURLSessionObserving
NetworkActivityIndicatorObserver
Shows and hides the Network Activity Indicator
automatically, based on the states of requests in the SAPURLSession
. It presents the indicator when a request starts and hides it when the request finished.
The state of the ActivityIndicator is shared among all the SAPURLSession
and SAPURLSessionObserving
instances.
The observer uses the NetworkActivityIndicatorController
to control the presentation of the indicator.
When you use this observer never modify the Network Activity Indicator
directly but use the NetworkActivityIndicatorController
.
The code snippet below demonstrates how to use it:
let indicatorObserver = NetworkActivityIndicatorObserver()
sapURLSession.register(indicatorObserver)
-
Initialises a new instance.
Declaration
Swift
public init()
-
Declaration
Swift
public func sapURLSession(_ session: SAPURLSession, task: SAPURLSessionTask, willSend request: URLRequest, completionHandler: @escaping (SAPURLSession.RequestDisposition) -> Void)
-
When a request is resent internally, the didCompleteWithError delegate is not called. There is no network communication at this point, so we have to hide the activity indicator.
Declaration
Swift
public func sapURLSession(_ session: SAPURLSession, task: SAPURLSessionTask, didCreate sessionTask: URLSessionTask)
-
Declaration
Swift
public func sapURLSession(_ session: SAPURLSession, task: SAPURLSessionTask, didCompleteWithError error: Error?)
-
Undocumented
Declaration
Swift
public func copy() -> Any?