您的位置:首页 > 理论基础 > 计算机网络

网络工具类

2016-01-31 09:49 316 查看
#import "AFHTTPRequestOperationManager.h"

@interface NetworkTools : AFHTTPRequestOperationManager

+ (instancetype)shareNetworkTools;
@end

#import "NetworkTools.h"

@implementation NetworkTools

+ (instancetype)shareNetworkTools
{
static id instance;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
NSURL *url = [NSURL URLWithString:@"http://xxxxxxx/"];
instance = [[self alloc] initWithBaseURL:url];
});
return instance;
}
@end

#import "AFHTTPSessionManager.h"

@interface NetworkTools2 : AFHTTPSessionManager
+ (instancetype)shareNetworkTools;
@end

#import "NetworkTools2.h"

@implementation NetworkTools2
+ (instancetype)shareNetworkTools
{
static id instance;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
// 注意: 在指定baseURL的时候, 后面需要加上/
NSURL *url = [NSURL URLWithString:@"http://xxxxxxxxx/"];
instance = [[self alloc] initWithBaseURL:url sessionConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];
});
return instance;
}
@end
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: