- (void)viewDidLoad {
[super viewDidLoad];
[self monitorNetWorkType];
// Do any additional setup after loading the view, typically from a nib.
}
/**
* AFNetworkReachabilityStatusUnknown = -1,
AFNetworkReachabilityStatusNotReachable = 0,
AFNetworkReachabilityStatusReachableViaWWAN = 1,
AFNetworkReachabilityStatusReachableViaWiFi = 2,
*/
-(void)monitorNetWorkType
{
//
AFHTTPRequestOperationManager *manager = [[AFHTTPRequestOperationManager alloc]initWithBaseURL:[NSURL URLWithString:@"www.baidu.com"]];
// block
[manager.reachabilityManager setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
if (status == AFNetworkReachabilityStatusReachableViaWiFi) {
NSLog(@"WIFI");
}else if(status == AFNetworkReachabilityStatusReachableViaWWAN)
{
NSLog(@"3G/GPRS");
}else if(status == AFNetworkReachabilityStatusNotReachable)
{
NSLog(@" ");
}
}];
//
[manager.reachabilityManager startMonitoring];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end