Created
January 9, 2013 22:17
-
-
Save dragthor/4497511 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
/* Reachability *networkReachability = [Reachability reachabilityForInternetConnection]; | |
NetworkStatus networkStatus = [networkReachability currentReachabilityStatus]; | |
if (networkStatus == NotReachable) { | |
NSLog(@"There IS NO internet connection"); | |
} else { | |
NSLog(@"There IS internet connection"); | |
} */ | |
- (void) configureTextField: (UITextField*) textField imageView: (UIImageView*) imageView reachability: (Reachability*) curReach | |
{ | |
NetworkStatus netStatus = [curReach currentReachabilityStatus]; | |
BOOL connectionRequired= [curReach connectionRequired]; | |
NSString* statusString= @""; | |
switch (netStatus) | |
{ | |
case NotReachable: | |
{ | |
statusString = @"Access Not Available"; | |
imageView.image = [UIImage imageNamed: @"stop-32.png"] ; | |
//Minor interface detail- connectionRequired may return yes, even when the host is unreachable. We cover that up here... | |
connectionRequired= NO; | |
break; | |
} | |
case ReachableViaWWAN: | |
{ | |
statusString = @"Reachable WWAN"; | |
imageView.image = [UIImage imageNamed: @"WWAN5.png"]; | |
break; | |
} | |
case ReachableViaWiFi: | |
{ | |
statusString= @"Reachable WiFi"; | |
imageView.image = [UIImage imageNamed: @"Airport.png"]; | |
break; | |
} | |
} | |
if(connectionRequired) | |
{ | |
statusString= [NSString stringWithFormat: @"%@, Connection Required", statusString]; | |
} | |
textField.text= statusString; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment