2. Check the network status

Source: Internet
Author: User

 

  

    

  

                   - (         - (IBAction)testNetStatus:(     NSString *site =     Reachability *reach =                           [self showAlert:[NSString stringWithFormat:                                            [self showAlert:[NSString stringWithFormat:                                                [self showAlert:[NSString stringWithFormat:                       - (IBAction)testWifi:(      ([[Reachability reachabilityForLocalWiFi] currentReachabilityStatus] !=         [self showAlert:     }         [self showAlert:     - (IBAction)testInternet:(      ([[Reachability reachabilityForInternetConnection] currentReachabilityStatus] !=         [self showAlert:     }         [self showAlert:    -() showAlert:(NSString*      UIAlertView *alert = [[UIAlertView alloc] initWithTitle: message:msg :nil cancelButtonTitle:         - (          

  

typedef = ,         ReachableViaWiFi,         ReachableViaWWAN      }NetworkStatus;

  

Method to obtain the network connection status. If the network connection status returns NotReachable, it indicates that this type of network is not connected.

 

        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reachabilityChanged:) name:kReachabilityChangedNotification     Reachability *reach = [Reachability reachabilityWithHostName:    [reach startNotifier];

This means that when the connection status of the Reachability changes, the default notification center will receive the notification, which triggers the reachabilityChanged: Method of the application delegate class, you also need to define the following methods in the application delegate class:

- () reachabilityChanged:(NSNotification*    Reachability *curReach = [note     NetworkStatus status = (status ==*alert = [[UIAlertView alloc] initWithTitle: message: :nil cancelButtonTitle:

   

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.