GitXplorerGitXplorer
A

NPReachability

public
170 stars
16 forks
0 issues

Commits

List of commits on branch master.
Verified
82229b8a4a60ed98296e18d811a0ab75df5c9268

Add deprecation notice to README

AAbizern committed 7 years ago
Verified
deb685e3e2e6ae498b6a9d5859db8f4a55e0bdd4

Merge pull request #4 from bryant1410/master

AAbizern committed 7 years ago
Unverified
f57d4b566e9a20e75d55dae0f130caa727661990

Fix broken Markdown headings

bbryant1410 committed 8 years ago
Unverified
cf516a44051560aa44f8a3b46cf9b14e32f5aeeb

Merge pull request #3 from wiruzx/patch-1

AAbizern committed 11 years ago
Unverified
26d1810c245df267581a8dec4c63405a53d23f05

Add syntax highlighting

wwiruzx committed 11 years ago
Unverified
84efe474027e9db8763800898c762ad8cedd0471

Correct formatting in README.md

AAbizern committed 11 years ago

README

The README file for this repository.

DEPRECATED

I don't use this library, as you can probably tell by how long it's been since it's been updated. I've marked it as deprecated on CocoaPods and will be removing it in 2018. If anybody would like to take over the pod let me know and I'll try and get it done.

NPReachability

NPReachability is an evolution of Apple's Reachability class that provides information about the network status. It has a slightly simpler interface; more concerned with the changes to the network status rather than monitoring a particular URL.

As well as supporting the original's Notification based monitoring, this class supports both KVO and Blocks, so you can choose whichever way of handling changes as your application requires.

This class is written as a singleton, so be sure to reference it as

NPReachability *reachability = [NPReachability sharedInstance];

Make sure you maintain a strong reference to at least one object of this class or else ARC will clean it up underneach you.

Block support

Handlers are declared as

typedef void (^ReachabilityHandler)(NPReachability *curReach);

This takes the NPReachability object as a parameter. As originally written this class passed the SCNetworkReachabilityFlags as a parameter, but you can get that and more by messaging the object directly

You add blocks to be executed when the network status changes by using:

- (id)addHandler:(ReachabilityHandler)handler;

This returns an opaque object which you should use to remove the handler at the appropriate time (in a dealloc, say) with:

- (void)removeHandler:(id)opaqueObject;

KVO support

Two properties can observed for changes to the network status:

@property (nonatomic, readonly, getter=isCurrentlyReachable) BOOL currentlyReachable;
@property (nonatomic, readonly) SCNetworkReachabilityFlags currentReachabilityFlags;

NSNotification

When the network status changes a NPReachabilityChangedNotification is sent with the NPReachability instance as the notification object.

Dependencies

  • Xcode 5.0+ for ARC support, automatic synthesis and compatibility libraries. This might work for Xcode 4.2+, but I haven't been able to test it.
  • The SystemConfiguration Framework should be added to your project.

Usage

Git

Add the project as a submodule to your project's repository and add the NPReachability.h and NPReachability.m files to your project.

CocoaPods

This is also available as a CocoaPod. If you're a Podder, then you already know what to do to add this to your project.

Direct files

Just add the NPReachability.h and NPReachability.m files to your project. But I think any of the previous two methods are preferable to this.

Example

Apple provided the Reachability Sample Code to demonstrate the use of their Reachability class. To see how to use this Class instead have a look at NPReachability-Example which shows the same project using NPReachability instead.

And finally...

Please use and improve! Patches accepted, or create an issue.

I'd love it if you could send me a note as to which app you're using it with!