JTSReachability 1.1.0

JTSReachability 1.1.0

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Dec 2014

Maintained by Jared Sinclair.



  • By
  • Jared Sinclair

An adaptation of Apple's Reachability with some block-based conveniences.

Usage

Usage is straightforward. Access the singleton instance of JTSReachabilityResponder via:

+ (instancetype)sharedInstance;

An object in your application registers a block to be executed whenever the network status changes between one of the three known states (none, Wi-fi, or cellular) as follows:

- (void)someSetupMethod {

    JTSReachabilityResponder *responder = [JTSReachabilityResponder sharedInstance];

    [responder addHandler:^(JTSNetworkStatus status) {
        // Respond to the value of "status"
    } forKey:@"MyReachabilityKey"];
} 

Your object is responsible for cleaning up after itself, typically in dealloc, as follows:

- (void)dealloc {

    JTSReachabilityResponder *responder = [JTSReachabilityResponder sharedInstance];

    [responder removeHandlerForKey:@"MyReachabilityKey"];
}

All blocks are called on the main thread, and must be added or removed on the main thread.