#define AFWEBAPI_REQUEST_TIMEOUT 20
#pragma mark - 单例 & 构造函数
+ (instancetype)sharedTools {
static WXNetworkTools *instance;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
instance = [[self alloc] initWithBaseURL:[NSURL URLWithString:WX_SERVER_URL]];
instance.requestSerializer.timeoutInterval = AFWEBAPI_REQUEST_TIMEOUT;
});
return instance;
}
/// @param finished 完成回调
- (void)requestWithMethod:(WXRequestMethod)method URLString:(NSString *)URLString parameters:(id)parameters finished:(WXRequestCallBack)finished {
NSString *methodName = (method == GET) ? @"GET" : @"POST";
NSLog(@"%@",URLString);
[[self dataTaskWithHTTPMethod:methodName URLString:URLString parameters:parameters uploadProgress:nil downloadProgress:nil success:^(NSURLSessionDataTask *task, id responseObject) {
finished(responseObject, nil);
if (responseObject[@"status"] && [responseObject[@"status"] integerValue] == 1000) {
//这里来账号互踢
[[NSNotificationCenter defaultCenter] postNotificationName:KMutualKickNotification object:nil];
return;
}
} failure:^(NSURLSessionDataTask *task, NSError *error) {
NSLog(@"网络请求错误 %@", error);
//这里来处理网络超时
if (error.code == -1001) {
[SVProgressHUD showErrorWithStatus:@"网络超时!"];
return ;
}
finished(nil, error);
}] resume];
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有