Skip to content

Instantly share code, notes, and snippets.

@dragthor
Created January 9, 2013 22:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dragthor/4497511 to your computer and use it in GitHub Desktop.
Save dragthor/4497511 to your computer and use it in GitHub Desktop.
/* 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