TRCNetworkReachabilityManager Class Reference

TRCNetworkReachabilityManager is AFNetworkReachabilityManager copy from AFNetworking library. More...

Inheritance diagram for TRCNetworkReachabilityManager:

Properties

TRCNetworkReachabilityStatus networkReachabilityStatus
 The current network reachability status. More...
 
BOOL reachable
 Whether or not the network is currently reachable. More...
 
BOOL reachableViaWWAN
 Whether or not the network is currently reachable via WWAN. More...
 
BOOL reachableViaWiFi
 Whether or not the network is currently reachable via WiFi. More...
 

Instance Methods

Starting & Stopping Reachability Monitoring


(void) - startMonitoring
 Starts monitoring for changes in network reachability status. More...
 
(void) - stopMonitoring
 Stops monitoring for changes in network reachability status. More...
 
Getting Localized Reachability Description


(NSString *) - localizedNetworkReachabilityStatusString
 Returns a localized string representation of the current network reachability status. More...
 
Setting Network Reachability Change Callback


(void) - setReachabilityStatusChangeBlock:
 Sets a callback to be executed when the network availability of the baseURL host changes. More...
 

Initialization



(instancetype) + sharedManager
 Returns the shared network reachability manager. More...
 
(instancetype) + managerForDomain:
 Creates and returns a network reachability manager for the specified domain. More...
 
(instancetype) + managerForAddress:
 Creates and returns a network reachability manager for the socket address. More...
 
(instancetype) - initWithReachability:
 Initializes an instance of a network reachability manager from the specified reachability object. More...
 

Detailed Description

TRCNetworkReachabilityManager is AFNetworkReachabilityManager copy from AFNetworking library.

It has another prefix to avoid possible 'duplicate symbol' linker issue TRCNetworkReachabilityManager monitors the reachability of domains, and addresses for both WWAN and WiFi network interfaces.

Reachability can be used to determine background information about why a network operation failed, or to trigger a network operation retrying when a connection is established. It should not be used to prevent a user from initiating a network request, as it's possible that an initial request may be required to establish reachability.

See Apple's Reachability Sample Code (https://developer.apple.com/library/ios/samplecode/reachability/)

Warning
Instances of TRCNetworkReachabilityManager must be started with -startMonitoring before reachability status can be determined.

Property Documentation

◆ networkReachabilityStatus

- (TRCNetworkReachabilityStatus) networkReachabilityStatus
readnonatomicassign

The current network reachability status.

◆ reachable

- (BOOL) reachable
readnonatomicassign

Whether or not the network is currently reachable.

◆ reachableViaWWAN

- (BOOL) reachableViaWWAN
readnonatomicassign

Whether or not the network is currently reachable via WWAN.

◆ reachableViaWiFi

- (BOOL) reachableViaWiFi
readnonatomicassign

Whether or not the network is currently reachable via WiFi.

Method Documentation

◆ sharedManager()

+ (instancetype) sharedManager

Returns the shared network reachability manager.

◆ managerForDomain:()

+ (instancetype) managerForDomain: (NSString *)  domain

Creates and returns a network reachability manager for the specified domain.

Parameters
domainThe domain used to evaluate network reachability.
Returns
An initialized network reachability manager, actively monitoring the specified domain.

◆ managerForAddress:()

+ (instancetype) managerForAddress: (const void *)  address

Creates and returns a network reachability manager for the socket address.

Parameters
addressThe socket address (sockaddr_in) used to evaluate network reachability.
Returns
An initialized network reachability manager, actively monitoring the specified socket address.

◆ initWithReachability:()

- (instancetype) initWithReachability: (SCNetworkReachabilityRef)  NS_DESIGNATED_INITIALIZER

Initializes an instance of a network reachability manager from the specified reachability object.

Parameters
reachabilityThe reachability object to monitor.
Returns
An initialized network reachability manager, actively monitoring the specified reachability.

◆ startMonitoring()

- (void) startMonitoring

Starts monitoring for changes in network reachability status.

◆ stopMonitoring()

- (void) stopMonitoring

Stops monitoring for changes in network reachability status.

◆ localizedNetworkReachabilityStatusString()

- (NSString *) localizedNetworkReachabilityStatusString

Returns a localized string representation of the current network reachability status.

◆ setReachabilityStatusChangeBlock:()

- (void) setReachabilityStatusChangeBlock: (void(^)(TRCNetworkReachabilityStatus status))  block

Sets a callback to be executed when the network availability of the baseURL host changes.

Parameters
blockA block object to be executed when the network availability of the baseURL host changes.. This block has no return value and takes a single argument which represents the various reachability states from the device to the baseURL.