Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: c8a3e521ee
Fetching contributors…

Cannot retrieve contributors at this time

48 lines (33 sloc) 1.985 kb


This is a drop-in replacement for Apples Reachability class. It is ARC compatible, uses the new GCD methods to notify of network interface changes.

In addition to the standard NSNotification it supports the use of Blocks for when the network becomes reachable and unreachable.

Finally you can specify wether or not a WWAN connection is considered "reachable".

A Simple example

This sample uses Blocks to tell you when the interface state has changed. The blocks will be called on a BACKGROUND THREAD so you need to dispatch UI updates onto the main thread.

// allocate a reachability object
Reachability* reach = [Reachability reachabilityWithHostname:@""];

// set the blocks 
reach.reachableBlock = ^(Reachability*reach)

reach.unreachableBlock = ^(Reachability*reach)

// start the notifier which will cause the reachability object to retain itself!
[reach startNotifier];

Another simple example

This sample will use NSNotifications to tell you when the interface has changed, they will be delivered on the MAIN THREAD so you can do UI updates from within the function.

In addition it asks the Reachability object to consider the WWAN (3G/EDGE/CDMA) as a non-reachable connection (you might use this if you are writing a video streaming app, for example, to save the users data plan).

// allocate a reachability object
Reachability* reach = [Reachability reachabilityWithHostname:@""];

// tell the reachability that we DONT want to be reachable on 3G/EDGE/CDMA
reach.reachableOnWWAN = NO;

// here we set up a NSNotification observer. The Reachability that caused the notification
// is passed in the object parameter
[[NSNotificationCenter defaultCenter] addObserver:self 

[reach startNotifier]
Jump to Line
Something went wrong with that request. Please try again.