TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Feb 2017 |
LEONetworkKit is a part of LEOKit. Have fun!
In me the tiger sniffs the rose.
心有猛虎,细嗅蔷薇。
Welcome to my blog: http://LeoDev.me
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);
}
startInternetNotifier
.Add network status changed notification:
// Network status changed
extern NSString *const kLEONetworkStatusChangedNotification;
If you have any question, just commit the issue! Thank you!
Mail: [email protected]
Blog: http://LeoDev.me