版权声明:本文为博主原创文章,未经博主允许不得转载。 https://cloud.tencent.com/developer/article/1338176
AFHTTPRequestOperationManager * net = AFHTTPRequestOperationManager manager;
// 检测网络状态
[net.reachabilityManager setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
if (status == AFNetworkReachabilityStatusReachableViaWiFi) {
UIAlertView * alert = [UIAlertView alloc initWithTitle:@"提示" message:@"您当前使用的网络是wifi" delegate:self cancelButtonTitle:@"我懂!!!" otherButtonTitles:nil, nil];
alert show;
NSLog(@"WIFI");
}
else if (status == AFNetworkReachabilityStatusReachableViaWWAN)
{
NSLog(@"2G/3G/4G");
}
else
{
NSLog(@"未知");
}
}];
// 开始检测
net.reachabilityManager startMonitoring;