Latest 1.2.0
Homepage https://github.com/VerticodeLabs/VCLReachability
License MIT
Platforms ios 7.0, requires ARC
Authors

VCLReachability is a reachability library for iOS. It is designed to help you interface with network activity events by allowing all objects to publish and subscribe to reachability events.

Based on Apples Reachability project.

Supported iOS SDK Versions

  • Supported build target – iOS 7.0

ARC Compatibility

VCLReachability works both with ARC.

Table of contents

Quick start

Four quick start options are available:

  • Download the latest release and add the source from Classes to your project.

  • Clone the repo and use the example project:

    [email protected]:VerticodeLabs/VCLReachability.git
    pod install
  • Install with Cocoapods by adding VCLReachability to your Podfile.
    pod `VCLReachability`

What’s included

Within the download you’ll find the following files, providing both compiled and minified variations:

Classes/
└── ios/
    ├── NSObject+VCLReachabilitySubscriber.h
    └── NSObject+VCLReachabilitySubscriber.m
    └── VCLReachability.h
    └── VCLReachability.m
    └── VCLReachability.h
Examples/
├── ...
Tests/
├── ...
VCLReachability.xcodeproj/
├── ...

Sample Usage

IMPORTANT: VCLReachability must use DNS to resolve the host name before it can determine the VCLReachability of that host, and this may take time on certain network connections. Because of this, the API will return NotReachable until name resolution has completed. This delay may be visible in the interface on some networks.

The VCLReachability sample demonstrates the asynchronous use of the SCNetworkReachability API. You can use the API synchronously, but do not issue a synchronous check by hostName on the main thread. If the device cannot reach a DNS server or is on a slow network, a synchronous call to the SCNetworkReachabilityGetFlags function can block for up to 30 seconds trying to resolve the hostName. If this happens on the main thread, the application watchdog will kill the application after 20 seconds of inactivity.

SCNetworkReachability API’s do not currently provide a means to detect support for GameKit peer-to-peer networking over Bluetooth.

Using the VCLReachabilitySubscriber Protocol

Add VCLReachabilitySubscriber.h to the class you which to become a reachability subscriber.

#import "VCLReachabilitySubscriber.h"

Implement the protocol method

- (void)reachabilityChanged:(NSNotification *)note{...}
- (void)wifiReachabilityChanged:(NSNotification *)note{...}
- (void)internetReachabilityChanged:(NSNotification *)note{...}
- (void)hostNameReachabilityChanged:(NSNotification *)note{...}

For example….

- (void)reachabilityChanged:(NSNotification *)note
{
    VCLReachability* curReach = [note object];
    NSParameterAssert([curReach isKindOfClass:[VCLReachability class]]);

    [(id<VCLReachabilitySubscriber>)self updateWithReachability:curReach forType:nil];
}

Using the VCLReachability Category

Add NSObject+VCLReachabilitySubscriber.h to the class you which to become a reachability subscriber.

#import "NSObject+VCLReachabilitySubscriber.h"

The VCLReachabilitySubscriber protocol methods will aready be filled in. By default every subscriber will execute - (void)updateWithReachability:(VCLReachability *)reachability forType:(NSString*)type; unless the other optional protocol methods are defined. Be sure to define updateWithReachability in your subscriber.

Subscribe to Network Events

The following methods are used to subscribe to different reachability events.

/*!
 * Subscribe change it network events
 */
+ (void)subscribeToReachabilityNotificationsWithDelegate:(id<VCLReachabilitySubscriber>) delegate;
+ (void)subscribeToReachabilityForWifiWithDelegate:(id<VCLReachabilitySubscriber>) delegate;
+ (void)subscribeToReachabilityForHostNameWithName:(NSString *)hostName delegate:(id<VCLReachabilitySubscriber>) delegate;
+ (void)subscribeToReachabilityForInternetConnectionWithDelegate:(id<VCLReachabilitySubscriber>) delegate;

For example…

- (void)viewDidLoad
{  
    [VCLReachability subscribeToReachabilityForHostNameWithName:@"google.com" delegate:self];
    [VCLReachability subscribeToReachabilityForInternetConnectionWithDelegate:self];
    [VCLReachability subscribeToReachabilityForWifiWithDelegate:self];
}

NOTE:
Make sure you unsubscribe your delegates before they go bad by using the VCLReachability classes unsubscribe methods. I suggest that you do this within dealloc.

ChangeLog

Refer to the releases section for a detailed ChangeLog

Bugs and feature requests

Have a bug or a feature request? Please first read the [issue guidelines](#using-the-issue-tracker) and search for existing and closed issues. If your problem or idea is not addressed yet, please open a new issue.

Contributing

Please read through our contributing guidelines. Included are directions for opening issues, coding standards, and notes on development.

More over, if your pull request contains patches or features, you must include relevant unit tests.

Community

Keep track of development and updates.

Versioning

For transparency into our release cycle and in striving to maintain backward compatibility, this project is maintained under the Semantic Versioning guidelines. Sometimes we screw up, but we’ll adhere to these rules whenever possible.

Releases will be numbered with the following format:

<major>.<minor>.<patch>

And constructed with the following guidelines:

  • Breaking backward compatibility bumps the major while resetting minor and patch
  • New additions without breaking backward compatibility bumps the minor while resetting the patch
  • Bug fixes and misc changes bumps only the patch

For more information on SemVer, please visit http://semver.org/.

Authors

Adrian Maurer

License

Licensed under the MIT license.

Latest podspec

{
    "name": "VCLReachability",
    "version": "1.2.0",
    "summary": "VCLReachability is a network reachability library for iOS. It is designed to help you interface with network activity.",
    "description": "                       # VCLReachabilitynn                      VCLReachability is a reachability library for iOS. It is designed to help you interface with network activity events by allowing all objects to publish and subscribe to reachability events. nn                      Based on Apples [Reachability](https://developer.apple.com/Library/ios/samplecode/Reachability/Introduction/Intro.html) project.nn                      ### Supported iOS SDK Versionsnn                      * Supported build target - iOS 7.0nn                      ### ARC Compatibilitynn                      VCLReachability works both with ARC.nn                      ## Table of contentsnn                      - [Quick start](#quick-start)n                      - [ChangeLog](#changelog)n                      - [Documentation](#documentation)n                      - [Bugs and feature requests](#bugs-and-feature-requests)n                      - [Contributing](#contributing)n                      - [Community](#community)n                      - [Versioning](#versioning)n                      - [Authors](#authors)n                      - [License](#license)nn                      ## Quick startnn                      Four quick start options are available:nn                      - [Download the latest release](https://github.com/VerticodeLabs/VCLReachability/releases) and add the source from `Classes` to your project.nn                      - Clone the repo and use the example project: n                      ```bashn                      [email protected]:VerticodeLabs/VCLReachability.gitn                      ```nn                      - Install with [Cocoapods](http://cocoapods.org/) by adding VCLReachability to your Podfile.n                      ```bashn                      pod `VCLReachability`n                      ```nn                      ### What's includednn                      Within the download you'll find the following files, providing both compiled and minified variations:nn                      ```n                      Classes/n                      u2514u2500u2500 ios/n                          u251cu2500u2500 NSObject+VCLReachabilitySubscriber.hn                          u2514u2500u2500 NSObject+VCLReachabilitySubscriber.mn                          u2514u2500u2500 VCLReachability.hn                          u2514u2500u2500 VCLReachability.mn                          u2514u2500u2500 VCLReachability.hn                      Examples/n                      u251cu2500u2500 ...n                      Tests/n                      u251cu2500u2500 ...n                      VCLReachability.xcodeproj/n                      u251cu2500u2500 ...nn                      ```nn                      ### Sample Usagenn                      IMPORTANT: VCLReachability must use DNS to resolve the host name before it can determine the VCLReachability of that host, and this may take time on certain network connections.  Because of this, the API will return NotReachable until name resolution has completed.  This delay may be visible in the interface on some networks.nn                      The VCLReachability sample demonstrates the asynchronous use of the SCNetworkReachability API. You can use the API synchronously, but do not issue a synchronous check by hostName on the main thread. If the device cannot reach a DNS server or is on a slow network, a synchronous call to the SCNetworkReachabilityGetFlags function can block for up to 30 seconds trying to resolve the hostName. If this happens on the main thread, the application watchdog will kill the application after 20 seconds of inactivity.nn                      SCNetworkReachability API's do not currently provide a means to detect support for GameKit peer-to-peer networking over Bluetooth.nn                      #### Using the VCLReachabilitySubscriber Protocolnn                      Add `VCLReachabilitySubscriber.h` to the class you which to become a reachability subscriber.nn                      ```objective-cn                      #import "VCLReachabilitySubscriber.h"n                      ```n                      Implement the protocol methodnn                      ```objective-cn                      - (void)reachabilityChanged:(NSNotification *)note{...}n                      - (void)wifiReachabilityChanged:(NSNotification *)note{...}n                      - (void)internetReachabilityChanged:(NSNotification *)note{...}n                      - (void)hostNameReachabilityChanged:(NSNotification *)note{...}n                      ```nn                      For example....nn                      ```objective-cn                      - (void)reachabilityChanged:(NSNotification *)noten                      {n                          VCLReachability* curReach = [note object];n                          NSParameterAssert([curReach isKindOfClass:[VCLReachability class]]);n                          n                          [(id)self updateWithReachability:curReach forType:nil];n                      }n                      ```nn                      #### Using the VCLReachability Categorynn                      Add `NSObject+VCLReachabilitySubscriber.h` to the class you which to become a reachability subscriber.nn                      ```objective-cn                      #import "NSObject+VCLReachabilitySubscriber.h"n                      ```nn                      The VCLReachabilitySubscriber protocol methods will aready be filled in. By default every subscriber will execute `- (void)updateWithReachability:(VCLReachability *)reachability forType:(NSString*)type;` unless the other optional protocol methods are defined. Be sure to define `updateWithReachability` in your subscriber.nn                      #### Subscribe to Network Eventsnn                      The following methods are used to subscribe to differente reachability events.nn                      ```objective-cn                      /*!n                       * Subscribe change it network eventsn                       */n                      + (void)subscribeToReachabilityNotificationsWithDelegate:(id) delegate;n                      + (void)subscribeToReachabilityForWifiWithDelegate:(id) delegate;n                      + (void)subscribeToReachabilityForHostNameWithName:(NSString *)hostName delegate:(id) delegate;n                      + (void)subscribeToReachabilityForInternetConnectionWithDelegate:(id) delegate;n                      ```nn                      For example...nn                      ```objective-cn                      - (void)viewDidLoadn                      {  n                          [VCLReachability subscribeToReachabilityForHostNameWithName:@"google.com" delegate:self];n                          [VCLReachability subscribeToReachabilityForInternetConnectionWithDelegate:self];n                          [VCLReachability subscribeToReachabilityForWifiWithDelegate:self];n                      }n                      ```n                      **NOTE**n                      Make sure you unsubscribe your delegates before they go bad by using the VCLReachability classes unsubscribe methods. I suggest that you do this within `dealloc`.nn                      ## ChangeLogn                      Refer to the [releases](https://github.com/VerticodeLabs/VCLReachability/releases) section for a detailed ChangeLognn                      nn                      ## Bugs and feature requestsnn                      Have a bug or a feature request? Please first read the [issue guidelines](#using-the-issue-tracker) and search for existing and closed issues. If your problem or idea is not addressed yet, [please open a new issue](https://github.com/VerticodeLabs/VCLReachability/issues/new).nn                      ## Contributingnn                      Please read through our [contributing guidelines](CONTRIBUTING.md). Included are directions for opening issues, coding standards, and notes on development.nn                      More over, if your pull request contains patches or features, you must include relevant unit tests.nn                      ## Communitynn                      Keep track of development and updates.nn                      - Follow [@adrianmaurer](http://twitter.com/adrianmaurer) & [@VerticodeLabs](http://twitter.com/verticodelabs) on Twitter.n                      - Tweet [@VerticodeLabs](http://twitter.com/verticodelabs) with any questions/personal support requests.n                      - Read and subscribe to [my site](http://verticodelabs.com).nn                      ## Versioningnn                      For transparency into our release cycle and in striving to maintain backward compatibility, this project is maintained under the Semantic Versioning guidelines. Sometimes we screw up, but we'll adhere to these rules whenever possible.nn                      Releases will be numbered with the following format:nn                      `..`nn                      And constructed with the following guidelines:nn                      - Breaking backward compatibility **bumps the major** while resetting minor and patchn                      - New additions without breaking backward compatibility **bumps the minor** while resetting the patchn                      - Bug fixes and misc changes **bumps only the patch**nn                      For more information on SemVer, please visit .nn                      ## Authorsnn                      **Adrian Maurer**nn                      - Twitter: [@adrianmaurer](http://twitter.com/adrianmaurer)n                      - Website: [verticodelabs.com](http://verticodelabs.com)nn                      ## Licensenn                      Licensed under [the MIT license](LICENSE).nn",
    "homepage": "https://github.com/VerticodeLabs/VCLReachability",
    "documentation_url": "https://github.com/VerticodeLabs/VCLReachability/blob/master/README.md",
    "license": "MIT",
    "authors": {
        "adrianmaurer": "[email protected]"
    },
    "source": {
        "git": "https://github.com/VerticodeLabs/VCLReachability.git",
        "tag": "1.2.0"
    },
    "social_media_url": "https://twitter.com/verticodelabs",
    "platforms": {
        "ios": "7.0"
    },
    "requires_arc": true,
    "source_files": "Classes/**/*.{h,m}",
    "ios": {
        "exclude_files": "Classes/osx"
    },
    "osx": {
        "exclude_files": "Classes/ios"
    }
}

Pin It on Pinterest

Share This