I'm using the following implementation to check if there's s internet connection avaliable, and it's working fine, but because I'm gonna check for a internet connection a lot I think it's best for (BOOL)reachable method to be avaliable everywhere without rewriting it everytime. Because I'm new to iOS development I'm not sure how to do that. What's the best way to do that?
//
// SigninViewController.m
//
#import "Reachability.h"
#import "SigninViewController.h"
@implementation SigninViewController
...
- (IBAction)SigninTouchUpInside:(id)sender
{
if ([self reachable])
{
NSLog(@"Reachable");
}
else
{
NSLog(@"Not Reachable");
}
}
- (BOOL)reachable {
Reachability *reachability = [Reachability reachabilityWithHostName:@"enbr.co.cc"];
NetworkStatus internetStatus = [reachability currentReachabilityStatus];
if(internetStatus == NotReachable) {
return NO;
}
return YES;
}
@end