示例代码:使用之前请从Apple网站下载示例:点此下载
1、先倒入框架 :SystemConfiguration.framework
2、倒入三方类库:
Reachability.h
Reachability.m
-(void)viewWillAppear:(BOOL)animated
{
//判断网络是否断开
Reachability *reach = [Reachability reachabilityWithHostName:@"www.apple.com"];
switch ([reach currentReachabilityStatus]) {
case NotReachable:
NSLog(@"notReachable");
break;
case ReachableViaWiFi:
NSLog(@"WIFI");
break;
case ReachableViaWWAN:
NSLog(@"3G");
break;
}
}