explaingit

tonymillion/reachability

6,959Objective-CAudience · developerComplexity · 2/5Setup · easy

TLDR

Reachability is a tiny Objective-C library for iOS and macOS that tells your app whether the device has an internet connection and notifies you the moment that status changes, using modern block callbacks instead of delegates.

Mindmap

mindmap
  root((Reachability))
    What it does
      Detect internet status
      Change notifications
      WiFi vs cellular
    Tech Stack
      Objective-C
      Swift compatible
      GCD callbacks
    Use Cases
      Offline banners
      Data warning prompts
      Background sync pausing
    Setup
      Two files to copy
      Link SystemConfiguration
      Works in Xcode
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Detect network availability in an iOS app and show an offline banner when the connection drops.

USE CASE 2

Warn users before a data-heavy action if they are on a cellular connection rather than WiFi.

USE CASE 3

React to WiFi-to-cellular transitions in real time using block-based callbacks without polling the network.

USE CASE 4

Replace Apple's deprecated Reachability sample code with a modern drop-in that works in Swift and Objective-C.

Tech stack

Objective-CSwiftiOSmacOSGCD

Getting it running

Difficulty · easy Time to first run · 5min

Copy two files into your Xcode project and link the SystemConfiguration framework, do not bundle inside a shared framework to avoid App Store rejection.

In plain English

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.

Copy-paste prompts

Prompt 1
Add network reachability checking to my iOS Swift app using the Reachability library so I can show an offline message when the user has no internet.
Prompt 2
Configure Reachability to treat cellular connections as not reachable in my video streaming iOS app so I can warn users before burning their data plan.
Prompt 3
Migrate my app from Apple's old Reachability sample code to the tonymillion Reachability library using block-based callbacks instead of delegates.
Prompt 4
Write Swift code using Reachability to pause background sync tasks when there is no WiFi and resume them automatically when WiFi returns.
Prompt 5
Set up the Reachability library for a macOS app and print a log message whenever the connection status changes between WiFi and no network.
Open on GitHub → Explain another repo

← tonymillion on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.