Coder Social home page Coder Social logo

leonetworkkit's Introduction

LEONetworkKit

Travis CocoaPods CocoaPods CocoaPods LeoDev

LEONetworkKit is a part of LEOKit. Have fun!

In me the tiger sniffs the rose.

心有猛虎,细嗅蔷薇。

Welcome to my blog: http://LeoDev.me

Installation

CocoaPods

LEONetworkKit is available on CocoaPods. Just add the following to your project Podfile:

pod 'LEONetworkKit' # Podfile

Non-CocoaPods

Just drag the LEONetworkKit folder into your project.

Usage

  • In the AppDelegate.m:

     #import "LEONetworkKit.h"
    
     - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
         // Override point for customization after application launch.
         
         [LEONetworkStatus startInternetNotifier];
         
         return YES;
     }
  • Get network status anywhere:

     NetworkStatus status = [LEONetworkStatus status];
     
     NSLog(@"Network Status: %ld",  status);
  • Or you want observing network status changed notification:

     // Notifications
     // Network status changed
     extern NSString *const kLEONetworkStatusChangedNotification;
    
     // Network toggle to not reachable
     extern NSString *const kLEONetworkNotReachableNotification;
     // Network toggle to WiFi
     extern NSString *const kLEONetworkReachableViaWiFiNotification;
     // Network toggle to WWAN (Cellular)
     extern NSString *const kLEONetworkReachableViaWWANNotification;
    
    
     // Add observer
     [[NSNotificationCenter defaultCenter] addObserver:self
                                              selector:@selector(handleNetworkStatusChanged:)
                                                  name:kLEONetworkStatusChangedNotification
                                                object:nil];
     
    
     // Handle net work status changed
     - (void)handleNetworkStatusChanged:(NSNotification *)noti {
         Reachability *reach = noti.object;
         NSParameterAssert([reach isKindOfClass:[Reachability class]]);
         NetworkStatus status = reach.currentReachabilityStatus;
         
         NSLog(@"From Notification: %ld",  status);
     }

ChangeLog

V 0.0.4

  • Fix issue.

V 0.0.3

  • Update network status when call startInternetNotifier.

V 0.0.2

  • Add network status changed notification:

     // Network status changed
     extern NSString *const kLEONetworkStatusChangedNotification;

V 0.0.1

  • Hello world!

Thanks

Support

License

MIT License

leonetworkkit's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.