Skip to main content
Copy edited. Applied some formatting (as a result, the diff looks much more extensive than it really is).
Source Link
Peter Mortensen
  • 31.4k
  • 22
  • 110
  • 134

Very simple.... Try thisthese steps:

Step 1: Add  the SystemConfiguration framework into your project.


Step 2: Import the following code into your header file.

#import <SystemConfiguration/SystemConfiguration.h>

Step 3: Use the following method

      - Type 1:

- (BOOL) currentNetworkStatus {
    [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
    BOOL connected;
    BOOL isConnected;
    const char *host = "www.apple.com";
    SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithName(NULL, host);
    SCNetworkReachabilityFlags flags;
    connected = SCNetworkReachabilityGetFlags(reachability, &flags);
    isConnected = NO;
    isConnected = connected && (flags & kSCNetworkFlagsReachable) && !(flags & kSCNetworkFlagsConnectionRequired);
    CFRelease(reachability);
    return isConnected;
}
  • Type 1:

     - (BOOL) currentNetworkStatus {
         [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
         BOOL connected;
         BOOL isConnected;
         const char *host = "www.apple.com";
         SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithName(NULL, host);
         SCNetworkReachabilityFlags flags;
         connected = SCNetworkReachabilityGetFlags(reachability, &flags);
         isConnected = NO;
         isConnected = connected && (flags & kSCNetworkFlagsReachable) && !(flags & kSCNetworkFlagsConnectionRequired);
         CFRelease(reachability);
         return isConnected;
     }
    

      - Type 2:

Import header : #import "Reachability.h"

- (BOOL)currentNetworkStatus 
{
    Reachability *reachability = [Reachability reachabilityForInternetConnection];  
    NetworkStatus networkStatus = [reachability currentReachabilityStatus]; 
    return networkStatus != NotReachable;
}
  • Type 2:

    Import header : #import "Reachability.h"

     - (BOOL)currentNetworkStatus
     {
         Reachability *reachability = [Reachability reachabilityForInternetConnection];
         NetworkStatus networkStatus = [reachability currentReachabilityStatus];
         return networkStatus != NotReachable;
     }
    

Step 4: How to use..:

- (void)CheckInternet
{
    BOOL network = [self currentNetworkStatus];
    if (network)
    {
        NSLog(@"Network Available");
    }
    else
    {
        NSLog(@"No Network Available");
    }
}

Very simple.... Try this steps

Step 1: Add  SystemConfiguration framework into your project


Step 2: Import following code into your header file

#import <SystemConfiguration/SystemConfiguration.h>

Step 3: Use following method

      - Type 1:

- (BOOL) currentNetworkStatus {
    [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
    BOOL connected;
    BOOL isConnected;
    const char *host = "www.apple.com";
    SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithName(NULL, host);
    SCNetworkReachabilityFlags flags;
    connected = SCNetworkReachabilityGetFlags(reachability, &flags);
    isConnected = NO;
    isConnected = connected && (flags & kSCNetworkFlagsReachable) && !(flags & kSCNetworkFlagsConnectionRequired);
    CFRelease(reachability);
    return isConnected;
}

      - Type 2:

Import header : #import "Reachability.h"

- (BOOL)currentNetworkStatus 
{
    Reachability *reachability = [Reachability reachabilityForInternetConnection];  
    NetworkStatus networkStatus = [reachability currentReachabilityStatus]; 
    return networkStatus != NotReachable;
}

Step 4: How to use..

- (void)CheckInternet
{
    BOOL network = [self currentNetworkStatus];
    if(network)
    {
        NSLog(@"Network Available");
    }
    else
    {
        NSLog(@"No Network Available");
    }
}

Very simple.... Try these steps:

Step 1: Add the SystemConfiguration framework into your project.


Step 2: Import the following code into your header file.

#import <SystemConfiguration/SystemConfiguration.h>

Step 3: Use the following method

  • Type 1:

     - (BOOL) currentNetworkStatus {
         [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
         BOOL connected;
         BOOL isConnected;
         const char *host = "www.apple.com";
         SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithName(NULL, host);
         SCNetworkReachabilityFlags flags;
         connected = SCNetworkReachabilityGetFlags(reachability, &flags);
         isConnected = NO;
         isConnected = connected && (flags & kSCNetworkFlagsReachable) && !(flags & kSCNetworkFlagsConnectionRequired);
         CFRelease(reachability);
         return isConnected;
     }
    

  • Type 2:

    Import header : #import "Reachability.h"

     - (BOOL)currentNetworkStatus
     {
         Reachability *reachability = [Reachability reachabilityForInternetConnection];
         NetworkStatus networkStatus = [reachability currentReachabilityStatus];
         return networkStatus != NotReachable;
     }
    

Step 4: How to use:

- (void)CheckInternet
{
    BOOL network = [self currentNetworkStatus];
    if (network)
    {
        NSLog(@"Network Available");
    }
    else
    {
        NSLog(@"No Network Available");
    }
}
added 350 characters in body
Source Link
Rajesh Loganathan
  • 11.3k
  • 4
  • 80
  • 91

Very simple.... Try this steps

Step 1: Add SystemConfiguration framework into your project

 

Step 2: Import following code into your header file

#import <SystemConfiguration/SystemConfiguration.h>
 

Step 3: Use following method

      - Type 1:

- (BOOL) currentNetworkStatus {
    [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
    BOOL connected;
    BOOL isConnected;
    const char *host = "www.apple.com";
    SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithName(NULL, host);
    SCNetworkReachabilityFlags flags;
    connected = SCNetworkReachabilityGetFlags(reachability, &flags);
    isConnected = NO;
    isConnected = connected && (flags & kSCNetworkFlagsReachable) && !(flags & kSCNetworkFlagsConnectionRequired);
    CFRelease(reachability);
    return isConnected;
}

      - Type 2:

Import header : #import "Reachability.h"

- (BOOL)currentNetworkStatus 
{
    Reachability *reachability = [Reachability reachabilityForInternetConnection];  
    NetworkStatus networkStatus = [reachability currentReachabilityStatus]; 
    return networkStatus != NotReachable;
}
 

Step 4: How to use..

- (void)CheckInternet
{
    BOOL network = [self currentNetworkStatus];
    if(network)
    {
        NSLog(@"Network Available");
    }
    else
    {
        NSLog(@"No Network Available");
    }
}

Very simple.... Try this steps

Step 1: Add SystemConfiguration framework into your project

Step 2: Import following code into your header file

#import <SystemConfiguration/SystemConfiguration.h>

Step 3: Use following method

- (BOOL) currentNetworkStatus {
    [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
    BOOL connected;
    BOOL isConnected;
    const char *host = "www.apple.com";
    SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithName(NULL, host);
    SCNetworkReachabilityFlags flags;
    connected = SCNetworkReachabilityGetFlags(reachability, &flags);
    isConnected = NO;
    isConnected = connected && (flags & kSCNetworkFlagsReachable) && !(flags & kSCNetworkFlagsConnectionRequired);
    CFRelease(reachability);
    return isConnected;
}

Step 4: How to use..

- (void)CheckInternet
{
    BOOL network = [self currentNetworkStatus];
    if(network)
    {
        NSLog(@"Network Available");
    }
    else
    {
        NSLog(@"No Network Available");
    }
}

Very simple.... Try this steps

Step 1: Add SystemConfiguration framework into your project

 

Step 2: Import following code into your header file

#import <SystemConfiguration/SystemConfiguration.h>
 

Step 3: Use following method

      - Type 1:

- (BOOL) currentNetworkStatus {
    [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
    BOOL connected;
    BOOL isConnected;
    const char *host = "www.apple.com";
    SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithName(NULL, host);
    SCNetworkReachabilityFlags flags;
    connected = SCNetworkReachabilityGetFlags(reachability, &flags);
    isConnected = NO;
    isConnected = connected && (flags & kSCNetworkFlagsReachable) && !(flags & kSCNetworkFlagsConnectionRequired);
    CFRelease(reachability);
    return isConnected;
}

      - Type 2:

Import header : #import "Reachability.h"

- (BOOL)currentNetworkStatus 
{
    Reachability *reachability = [Reachability reachabilityForInternetConnection];  
    NetworkStatus networkStatus = [reachability currentReachabilityStatus]; 
    return networkStatus != NotReachable;
}
 

Step 4: How to use..

- (void)CheckInternet
{
    BOOL network = [self currentNetworkStatus];
    if(network)
    {
        NSLog(@"Network Available");
    }
    else
    {
        NSLog(@"No Network Available");
    }
}
deleted 8 characters in body
Source Link
Rajesh Loganathan
  • 11.3k
  • 4
  • 80
  • 91

Very simple.... Try this steps

Step 1: Add SystemConfiguration framework into your project

Step 2: Import following code into your header file

#import <SystemConfiguration/SystemConfiguration.h>

Step 3: Use following method

- (BOOL) currentNetworkStatus {
    [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
    BOOL connected;
    BOOL isConnected;
    const char *host = "www.apple.com";
    SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithName(NULL, host);
    SCNetworkReachabilityFlags flags;
    connected = SCNetworkReachabilityGetFlags(reachability, &flags);
    isConnected = NO;
    isConnected = connected && (flags & kSCNetworkFlagsReachable) && !(flags & kSCNetworkFlagsConnectionRequired);
    CFRelease(reachability);
    return isConnected;
}

Step 4: How to use..

- (void)CheckInternet
{
    BOOL network = [CheckNetwork[self currentNetworkStatus];
    if(network)
    {
        NSLog(@"Network Available");
    }
    else
    {
        NSLog(@"No Network Available");
    }
}

Very simple.... Try this steps

Step 1: Add SystemConfiguration framework into your project

Step 2: Import following code into your header file

#import <SystemConfiguration/SystemConfiguration.h>

Step 3: Use following method

- (BOOL) currentNetworkStatus {
    [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
    BOOL connected;
    BOOL isConnected;
    const char *host = "www.apple.com";
    SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithName(NULL, host);
    SCNetworkReachabilityFlags flags;
    connected = SCNetworkReachabilityGetFlags(reachability, &flags);
    isConnected = NO;
    isConnected = connected && (flags & kSCNetworkFlagsReachable) && !(flags & kSCNetworkFlagsConnectionRequired);
    CFRelease(reachability);
    return isConnected;
}

Step 4: How to use..

- (void)CheckInternet
{
    BOOL network = [CheckNetwork currentNetworkStatus];
    if(network)
    {
        NSLog(@"Network Available");
    }
    else
    {
        NSLog(@"No Network Available");
    }
}

Very simple.... Try this steps

Step 1: Add SystemConfiguration framework into your project

Step 2: Import following code into your header file

#import <SystemConfiguration/SystemConfiguration.h>

Step 3: Use following method

- (BOOL) currentNetworkStatus {
    [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
    BOOL connected;
    BOOL isConnected;
    const char *host = "www.apple.com";
    SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithName(NULL, host);
    SCNetworkReachabilityFlags flags;
    connected = SCNetworkReachabilityGetFlags(reachability, &flags);
    isConnected = NO;
    isConnected = connected && (flags & kSCNetworkFlagsReachable) && !(flags & kSCNetworkFlagsConnectionRequired);
    CFRelease(reachability);
    return isConnected;
}

Step 4: How to use..

- (void)CheckInternet
{
    BOOL network = [self currentNetworkStatus];
    if(network)
    {
        NSLog(@"Network Available");
    }
    else
    {
        NSLog(@"No Network Available");
    }
}
Source Link
Rajesh Loganathan
  • 11.3k
  • 4
  • 80
  • 91
Loading