SLRNetworkMonitor
Objective-C
@interface SLRNetworkMonitor : NSObject
Swift
class SLRNetworkMonitor : NSObject
@class SLRNetworkMonitor Provides a way of monitoring network connectivity on a device. Objects created with the default configuration create their own serial queue to handle events and then use the main queue to post notifications on.
-
The type of the monitor.
Declaration
Objective-C
@property (readonly) SLRNetworkMonitorType monitorType;
Swift
var monitorType: SLRNetworkMonitorType { get }
-
The current network path being monitored.
Declaration
Objective-C
@property (strong, readonly, nullable) nw_path_t currentPath;
Swift
var currentPath: nw_path_t? { get }
-
Designated initializer that creates a new instance of a
SLRNetworkMonitor
of a specific type, work queue, & notification queue.Note
Use-init
to get the default configuration.Declaration
Objective-C
- (nonnull instancetype)initWithMonitorType:(SLRNetworkMonitorType)monitorType workQueue:(nullable dispatch_queue_t)workQueue notificationQueue: (nullable dispatch_queue_t)notificationQueue;
Swift
init(monitorType: SLRNetworkMonitorType, work workQueue: DispatchQueue?, notificationQueue: DispatchQueue?)
Parameters
monitorType
The type of monitor to create.
workQueue
The queue that handles monitor operations.
notificationQueue
The queue to post status notifications to.
Return Value
A new instance of
SLRNetworkMonitor
with the specified configuration. -
Convenience initializer that creates a new instance of a
SLRNetworkMonitor
of a specific type, work queue, & notification queue.Note
Use+monitor
to get the default configuration.Declaration
Objective-C
+ (nonnull instancetype)monitorWithType:(SLRNetworkMonitorType)monitorType workQueue:(nullable dispatch_queue_t)workQueue notificationQueue: (nullable dispatch_queue_t)notificationQueue;
Swift
convenience init(type monitorType: SLRNetworkMonitorType, work workQueue: DispatchQueue?, notificationQueue: DispatchQueue?)
Parameters
monitorType
The type of monitor to create.
workQueue
The queue that handles monitor operations.
notificationQueue
The queue to post status notifications to.
Return Value
A new instance of
SLRNetworkMonitor
with the specified configuration. -
Convenience initializer that creates a new instance of a
SLRNetworkMonitor
with the default configuration.Declaration
Objective-C
+ (nonnull instancetype)monitor;
Return Value
A new instance of
SLRNetworkMonitor
with the default configuration. -
Tells a
SLRNetworkMonitor
to begin monitoring for network connectivity status changes.Declaration
Objective-C
- (void)startMonitoring;
Swift
func startMonitoring()
-
Tells a
SLRNetworkMonitor
to stop monitoring for network connectivity status changes.Declaration
Objective-C
- (void)stopMonitoring;
Swift
func stopMonitoring()