Question

I have this code in my AppDelegate:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{



    [[AFNetworkReachabilityManager sharedManager] setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {

        if (status == AFNetworkReachabilityStatusNotReachable){
            NSLog(@"NO CONNECTION");
        }
        else if (status == AFNetworkReachabilityStatusReachableViaWiFi || status == AFNetworkReachabilityStatusReachableViaWWAN){

            NSLog(@"YES CONNECTION");
        }
    }];

[[AFNetworkReachabilityManager sharedManager] startMonitoring];

return YES;
}

but it don't work, I have not my logs, why?

Était-ce utile?

La solution

The block is only called when the reachability actually changes.

You can get the current status like this:

[[AFNetworkReachabilityManager sharedManager] reachable]
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top