Reachability not working as expected

前端 未结 6 905
不思量自难忘°
不思量自难忘° 2021-02-19 02:53

Downloaded Reachability from Apple, using this method to check for an active connection:

-(BOOL)isReachable{

    Reachability *r = [Reachability reachabilityWit         


        
6条回答
  •  孤城傲影
    2021-02-19 03:37

    I use KSReachability. It works with NSNotification, blocks, KVO, and with or without ARC.

    KSReachability *reachability = [KSReachability reachabilityToHost:@"www.google.com"];
    reachability.onReachabilityChanged = ^(KSReachability* reachability) {
        NSLog(@"Update: network is %@", reachability.reachable ? @"up." : @"down.");
    };
    

提交回复
热议问题