- (void)viewDidLoad {
[superviewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[selfreachability];
}
- (void)reachability
{
//检测网络连接状态
[[AFNetworkReachabilityManagersharedManager] startMonitoring];
//连接状态回调处理
/* AFNetworking的Block内使用self须改为weakSelf,避免循环强引用, 无法释放 */
// __weak typeof(self) weakSelf = self;
[[AFNetworkReachabilityManagersharedManager] setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status)
{
switch (status)
{
caseAFNetworkReachabilityStatusUnknown:
// 回调处理
NSLog(@"1");
break;
caseAFNetworkReachabilityStatusNotReachable:
// 回调处理
NSLog(@"2");
break;
caseAFNetworkReachabilityStatusReachableViaWWAN:
// 回调处理
NSLog(@"3");
break;
caseAFNetworkReachabilityStatusReachableViaWiFi:
// 回调处理
NSLog(@"4");
break;
default:
break;
}
}];
}