asiHttpRequst 超时代码判断
2013-10-15 14:25 甘超波 阅读(591) 评论(0) 编辑 收藏 举报- (void)requestFailed:(ASIHTTPRequest *)request{ NSDictionary *userInfo = [request userInfo]; id delegate = [userInfo objectForKey:@"target"]; int conTag = [[userInfo objectForKey:@"tag"] intValue]; if ([delegate isKindOfClass:[UIViewController class]]) { UIViewController *ctl = (UIViewController*)delegate; [MBProgressHUD hideHUDForView:ctl.view animated:YES]; }else if([delegate isKindOfClass:[UIView class]]){ UIView *views = (UIView*)delegate; [MBProgressHUD hideHUDForView:views animated:YES]; } NSLog(@"错误信息:%@",[request error]); NSLog(@"\n失败--->>>>> ConnectId = %d 地址:%@ \n结果 %@",conTag,[[request url] absoluteString],[request responseString]); NSError *error = [request error]; NSInteger code = [error code]; if (code == 2) { // 请求超时 UIAlertView *av = [[UIAlertView alloc] initWithTitle:@"" message:@"请求超时" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil]; [av show]; [av release]; return; } UIAlertView *av = [[UIAlertView alloc] initWithTitle:@"" message:@"数据请求失败" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil]; [av show]; [av release]; }
目前我正在专注NLP,请立刻加微信/QQ号 546611623, 免费送你原创《NLP高级执行师》高清视频