Sportica   Sportica

iOS 网络检查

// 要用到Reachability.h  和Reachability.m两个文件 

-(void)checkNetworkRun 
{
     NSLog(@"newtwork44");
    SchoolInHandAppDelegate *app = [[UIApplication sharedApplication]delegate];
    Reachability *r = [Reachability reachabilityWithHostName:@"www.apple.com"];
    switch ([r currentReachabilityStatus]) 
    { 
        case NotReachable:
            //[self alertNONetwork];     网络弹出提示
            app.moudle.NetworkYesOrNo = NO;
            NSLog(@"没有网络");
            break;
        case ReachableViaWWAN:
            app.moudle.NetworkYesOrNo = YES;
            NSLog(@"正在使用3G网络");
            break;
        case ReachableViaWiFi:
            app.moudle.NetworkYesOrNo = YES;
            NSLog(@"正在使用wifi网络");  
            break;
        default:
            break;
    }
}
posted @ 2012-10-26 16:02  qingjoin  阅读(197)  评论(0编辑  收藏  举报
  Sportica