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.
- 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.
- iOS 11.0
- tvOS 11.0
- macOS 10.13
- Xcode 14.0
CocoaPods
pod 'TOReachability'
Carthage
github "TimOliver/TOReachability"
Manual Installation
Simply move the `TOReachability` folder to your Xcode project and import it.
TOReachability *reachability = [TOReachability reachabilityForInternetConnection];
reachability.statusChangedHandler = ^(TOReachabilityStatus newStatus) {
NSLog(@"Network Status Changed!");
};
[reachability start];
let reachability = Reachability.forInternetConnection()
reachability.statusChangedHandler = { newStatus in
print("Network Status Changed!")
}
reachability.start()
Developed by Tim Oliver as a component for iComics.
Device mockup by Mockups Design.
TOReachability
is licensed under the MIT License, please see the LICENSE file.