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?

Was it helpful?

Solution

The block is only called when the reachability actually changes.

You can get the current status like this:

[[AFNetworkReachabilityManager sharedManager] reachable]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top