Skip to content

Instantly share code, notes, and snippets.

@xinsight
Last active December 12, 2015 01:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xinsight/4690180 to your computer and use it in GitHub Desktop.
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.
_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