TOReachability 2.0.0

TOReachability 2.0.0

Maintained by Tim Oliver.



  • By
  • Tim Oliver

TOReachability

CI Version Carthage compatible GitHub license PayPal

A lightweight, unit-tested class that detects network status changes on iOS.

TOReachability is a small Objective-C class that can be used to detect when the current device changes its network status; between Wi-Fi, cellular, or none.

It based on, but is a completely new implementation of Apple's Reachability class. Compared to Reachability, apart from being properly name-spaced for Objective-C, it has been cleaned up to use modern Objective-C conventions, removes since deprecated features, and removes much of the unnecessary code Apple included.

While TOReachability only currently includes the most basic of functionality, it is definitely open to PRs when and if anyone has additional functionality they would like.

Features

  • Fully-unit tested.
  • Integrated with CocoaPods and Carthage.
  • Reactively executes callback logic whenever the network status of the current status changes.
  • Callback choices include blocks, delegates and NSNotification.
  • For cases where only Wi-Fi is needed, an option may be set to ignore cellular status changes.
  • Fully-bridged and tested to work in Swift.

Minimum Requirements

  • iOS 11.0
  • tvOS 11.0
  • macOS 10.13
  • Xcode 14.0

Installation Instructions

CocoaPods
pod 'TOReachability'
Carthage
github "TimOliver/TOReachability"
Manual Installation
Simply move the `TOReachability` folder to your Xcode project and import it.

Sample Code

Objective-C

TOReachability *reachability = [TOReachability reachabilityForInternetConnection];

reachability.statusChangedHandler = ^(TOReachabilityStatus newStatus) {
        NSLog(@"Network Status Changed!");
};

[reachability start];

Swift

let reachability = Reachability.forInternetConnection()

reachability.statusChangedHandler = { newStatus in
    print("Network Status Changed!")
}

reachability.start()

Credits

Developed by Tim Oliver as a component for iComics.

Device mockup by Mockups Design.

License

TOReachability is licensed under the MIT License, please see the LICENSE file.