- ( - (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: