Reachability Guide for iOS

I have implemented Reachability like this.
Download https://developer.apple.com/library/content/samplecode/Reachability/Introduction/Intro.html and add Reachability.h and .m to your project. Add the SystemConfiguration framework to your project. #import “Reachability.h” where you want to use it. Use this code.

-(BOOL)reachable {
    Reachability *r = [Reachability reachabilityWithHostName:@"enbr.co.cc"];
    NetworkStatus internetStatus = [r currentReachabilityStatus];
    if(internetStatus == NotReachable) {
        return NO;
    }
    return YES;
}

When you want to check for reachability…

if ([self reachable]) {
    NSLog(@"Reachable");
}
else {
    NSLog(@"Not Reachable");
}

Here is the example project that I made. http://dl.dropbox.com/u/3656129/ReachabilityExample.zip

Leave a Comment