Last active
December 12, 2015 01:18
-
-
Save xinsight/4690180 to your computer and use it in GitHub Desktop.
example of AFNetworking's nice wrapper to the Apple's hairy Reachability code.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_reachability = [[AFHTTPClient alloc] initWithBaseURL:[NSURL URLWithString:@"http://api.rdio.com/"]]; | |
[_reachability setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) { | |
switch (status) { | |
case AFNetworkReachabilityStatusNotReachable: | |
[self.reachabilityDelegate networkIsReachable:NO]; | |
break; | |
case AFNetworkReachabilityStatusReachableViaWiFi: | |
case AFNetworkReachabilityStatusReachableViaWWAN: | |
[self.reachabilityDelegate networkIsReachable:YES]; | |
break; | |
case AFNetworkReachabilityStatusUnknown: | |
NSLog(@"AFNetworkReachabilityStatusUnknown"); | |
break; | |
default: | |
NSLog(@"not handled: %d", status); | |
break; | |
} | |
}]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment