NetworkActivityIndicatorManager
public class NetworkActivityIndicatorManager
The NetworkActivityIndicatorManager
manages the state of the network activity indicator in the status bar. When
enabled, it will listen for notifications indicating that a URL session task has started or completed and start
animating the indicator accordingly. The indicator will continue to animate while the internal activity count is
greater than zero.
To use the NetworkActivityIndicatorManager
, the shared
instance should be enabled in the
application:didFinishLaunchingWithOptions:
method in the AppDelegate
. This can be done with the following:
NetworkActivityIndicatorManager.shared.isEnabled = true
By setting the isEnabled
property to true
for the shared
instance, the network activity indicator will show
and hide automatically as Alamofire requests start and complete. You should not ever need to call
incrementActivityCount
and decrementActivityCount
yourself.
-
The shared network activity indicator manager for the system.
Declaration
Swift
public static let shared: NetworkActivityIndicatorManager
-
A boolean value indicating whether the manager is enabled. Defaults to
false
.Declaration
Swift
public var isEnabled: Bool { get set }
-
A boolean value indicating whether the network activity indicator is currently visible.
Declaration
Swift
public private(set) var isNetworkActivityIndicatorVisible: Bool { get set }
-
A closure executed when the network activity indicator visibility changes.
Declaration
Swift
public var networkActivityIndicatorVisibilityChanged: ((Bool) -> Void)?
-
A time interval indicating the minimum duration of networking activity that should occur before the activity indicator is displayed. Defaults to
1.0
second.Declaration
Swift
public var startDelay: TimeInterval
-
A time interval indicating the duration of time that no networking activity should be observed before dismissing the activity indicator. This allows the activity indicator to be continuously displayed between multiple network requests. Without this delay, the activity indicator tends to flicker. Defaults to
0.2
seconds.Declaration
Swift
public var completionDelay: TimeInterval
-
Increments the number of active network requests. If this number was zero before incrementing, the network activity indicator will start spinning after the
startDelay
. Generally, this method should not need to be used directly.Declaration
Swift
public func incrementActivityCount()
-
Decrements the number of active network requests. If the number of active requests is zero after calling this method, the network activity indicator will stop spinning after the
completionDelay
. Generally, this method should not need to be used directly.Declaration
Swift
public func decrementActivityCount()