取消网络请求:
-(void)dealloc
{
[postData clearDelegatesAndCancel];
postData = nil;
}
判断当前是否有网络
/***
* 此函数用来判断是否网络连接服务器正常
* 需要导入Reachability类
*/
- (BOOL)isExistenceNetwork
{
BOOL isExistenceNetwork;
Reachability *reachability = [Reachability reachabilityWithHostName:@"www.apple.com"]; // 测试服务器状态
switch([reachability currentReachabilityStatus]) {
case NotReachable:
isExistenceNetwork = FALSE;
break;
case ReachableViaWWAN:
isExistenceNetwork = TRUE;
break;
case ReachableViaWiFi:
isExistenceNetwork = TRUE;
break;
}
return isExistenceNetwork;
}