Sometimes we need to check the availability of Internet for a particular functionality. Here is the Simple demo project on the same.

Steps:

  1. Create a new Xcode Project for (Single View Application).
  2. Give Project a name ( Lets say InternetConnectionDemo).
  3. Click next button and the Project will be created.
  4. Now go to this apple link Reachability and download two files(Reachabilty.h and

Reachability.m). Add thse two files in your Project folder.

5. Now go to your” ViewController.m” and import Reachability.h . Go to Your ViewDidLoad and write this code.

Reachability *reachabilityObj = [Reachability reachabilityForInternetConnection];
    
    NetworkStatus status = [reachabilityObj currentReachabilityStatus];
    if (!(status == NotReachable)) {
        
       Nslog(@”Internet Connection is present”);
        
    } else {
        
        Nslog(@”Internet Connection is not  present”);
        
    }

6. Run the code and see the desired output. Enjoy Coding 🙂

Advertisements