Detect network availability in an iOS app and show an offline banner when the connection drops.
Warn users before a data-heavy action if they are on a cellular connection rather than WiFi.
React to WiFi-to-cellular transitions in real time using block-based callbacks without polling the network.
Replace Apple's deprecated Reachability sample code with a modern drop-in that works in Swift and Objective-C.
Copy two files into your Xcode project and link the SystemConfiguration framework, do not bundle inside a shared framework to avoid App Store rejection.
Reachability is a small Objective-C library for iOS and macOS that tells your app whether the device currently has an internet connection, and notifies you when that status changes. It is a drop-in replacement for the older Reachability class that Apple used to ship as sample code. The main thing it adds over Apple's original is two modern conveniences. First, it uses blocks (short functions you pass inline) so your code can react to a connection change without setting up a separate delegate or notification handler. Second, it uses GCD (Apple's system for running tasks on specific threads), which makes the callbacks safer to use in modern app architectures. You can also tell it whether a mobile data connection (3G, LTE, and similar) counts as "reachable" for your purposes. If you are building a video streaming app and want to warn users before burning through their data plan, you can set reachable-on-WWAN to false, and the library will only treat WiFi as a real connection. Setup is minimal: copy two files into your project, link the SystemConfiguration framework (a one-click step in Xcode), and you are ready. The README gives working examples in both Objective-C and Swift 3. One active warning in the README: there have been reports of Apple rejecting apps when this library is bundled inside a framework. The suggested workaround is to rename the class before submitting to the App Store.
← tonymillion on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.