문제

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?

도움이 되었습니까?

해결책

The block is only called when the reachability actually changes.

You can get the current status like this:

[[AFNetworkReachabilityManager sharedManager] reachable]
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top