-
-
Save gliubc/1154563a5d49a84bcbe42b7a40e8407e to your computer and use it in GitHub Desktop.
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
#import <Reachability.h> | |
@property (strong, nonatomic) Reachability *internetReachableFoo; | |
// Checks if we have an internet connection or not | |
- (void)testInternetConnection | |
{ | |
self.internetReachableFoo = [Reachability reachabilityWithHostname:@"www.bing.com"]; | |
// Internet is reachable | |
@weakify(self); | |
self.internetReachableFoo.reachableBlock = ^(Reachability*reach) | |
{ | |
// Update the UI on the main thread | |
dispatch_async(dispatch_get_main_queue(), ^{ | |
@strongify(self); | |
[self loadRequest]; | |
NSLog(@"Yayyy, we have the interwebs!"); | |
}); | |
}; | |
// Internet is not reachable | |
self.internetReachableFoo.unreachableBlock = ^(Reachability*reach) | |
{ | |
// Update the UI on the main thread | |
dispatch_async(dispatch_get_main_queue(), ^{ | |
NSLog(@"Someone broke the internet :("); | |
}); | |
}; | |
[self.internetReachableFoo startNotifier]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment