Skip to content

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

License

Notifications You must be signed in to change notification settings

walsh2000/JTSReachability

Repository files navigation

JTSReachability

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.

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published