AWSKSReachability
Objective-C
@interface AWSKSReachability : NSObject
Swift
class AWSKSReachability : NSObject
Monitors network connectivity. *
- You can elect to be notified via blocks (onReachabilityChanged),
- notifications (notificationName), or KVO (flags, reachable, and WWANOnly). *
- All notification methods are disabled by default. *
Note
Upon construction, this object will fetch its initial reachability- state in the background. This means that the reachability status will ALWAYS
- be “unreachable” until some time after object construction (possibly up to 10
- seconds, depending on how long the DNS lookup takes). Use the “initialized”
- property to monitor initialization, or set the callback “onInitializationComplete”.
-
Reachability to a specific host. Returns nil if an initialization error occurs. *
- - parameter: hostname The name or IP address of the host to monitor. If nil or
- empty string, check reachability to the internet in general.
Declaration
Objective-C
+ (AWSKSReachability *)reachabilityToHost:(NSString *)hostname;
Swift
/*not inherited*/ init!(toHost hostname: String!)
-
Reachability to the local (wired or wifi) network. Returns nil if an initialization error occurs.
Declaration
Objective-C
+ (AWSKSReachability *)reachabilityToLocalNetwork;
Swift
class func toLocalNetwork() -> AWSKSReachability!
-
Reachability to the internet. Returns nil if an initialization error occurs.
Declaration
Objective-C
+ (AWSKSReachability *)reachabilityToInternet;
Swift
class func toInternet() -> AWSKSReachability!
-
The host we are monitoring reachability to, if any.
Declaration
Objective-C
@property (nonatomic, retain, readonly) NSString *hostname;
Swift
var hostname: String! { get }
-
If non-nil, called when the KSReachability object has finished initializing.
- If initialization has already completed, calls on the next main thread run loop.
- This block will only be called once, and then discarded (released).
- Block will be invoked on the main thread.
Declaration
Objective-C
@property (copy) AWSKSReachabilityCallback onInitializationComplete;
Swift
var onInitializationComplete: AWSKSReachabilityCallback! { get set }
-
If non-nil, called whenever reachability flags change.
- Block will be invoked on the main thread.
Declaration
Objective-C
@property (copy) AWSKSReachabilityCallback onReachabilityChanged;
Swift
var onReachabilityChanged: AWSKSReachabilityCallback! { get set }
-
The notification to send when reachability changes (nil = don’t send).
- Default = nil
Declaration
Objective-C
@property (nonatomic, retain) NSString *notificationName;
Swift
var notificationName: String! { get set }
-
The current reachability flags.
- This property will always report 0 while “initialized” property = NO.
Declaration
Objective-C
@property (nonatomic, readonly) SCNetworkReachabilityFlags flags;
Swift
var flags: SCNetworkReachabilityFlags { get }
-
Whether the host is reachable or not.
- This property will always report NO while “initialized” property = NO.
Declaration
Objective-C
@property (nonatomic, readonly) BOOL reachable;
Swift
var reachable: Bool { get }
-
Undocumented
Declaration
Objective-C
@property(nonatomic,readonly,assign) BOOL WWANOnly
Swift
var wwanOnly: Bool { get }
-
If YES, this object’s status properties are valid.
Declaration
Objective-C
@property (readonly) BOOL initialized;
Swift
var initialized: Bool { get }