Skip to content

Instantly share code, notes, and snippets.

@gliubc gliubc/.m
Created Apr 14, 2019

Embed
What would you like to do?
@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
You can’t perform that action at this time.