Created
August 13, 2012 05:38
-
-
Save raveman/3337210 to your computer and use it in GitHub Desktop.
Reachability test
This file contains hidden or 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" | |
| - (void)viewDidLoad | |
| { | |
| [super viewDidLoad]; | |
| [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reachabilityChanged:) name:kReachabilityChangedNotification object:nil]; | |
| Reachability * reach = [Reachability reachabilityWithHostname:@"www.google.com"]; | |
| [reach startNotifier]; | |
| } | |
| - (void)viewDidUnload | |
| { | |
| [super viewDidUnload]; | |
| [reach stopNotifier]; | |
| [[NSNotificationCenter defaultCenter] removeObserver:self]; | |
| } | |
| -(void)reachabilityChanged:(NSNotification*)note | |
| { | |
| Reachability * reach = [note object]; | |
| if([reach isReachable]){ | |
| NSLog(@"Notification Says Reachable"); | |
| } | |
| else { | |
| NSLog(@"Notification Says UnReachable"); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment