在開發(fā)項目的時候, 我們常常需要去判斷網(wǎng)路狀態(tài),強大的AFN為我們準備了一切.下面就來見證他的神奇吧
[manager setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
switch (status) {
case AFNetworkReachabilityStatusReachableViaWiFi:
[MBProgressHUD showMessage:@"切換到WIFI網(wǎng)絡(luò)"];
break;
case AFNetworkReachabilityStatusReachableViaWWAN:
[MBProgressHUD showMessage:@"切換到3/4G網(wǎng)絡(luò)"];
break;
case AFNetworkReachabilityStatusNotReachable:
[MBProgressHUD showMessage:@"網(wǎng)絡(luò)連接異常"];
break;
case AFNetworkReachabilityStatusUnknown:
[MBProgressHUD showMessage:@"未知網(wǎng)絡(luò)"];
break;
default:
break;
}
[MBProgressHUD hideHUD];
}];
[manager startMonitoring];