单例对AFNetworking的封装

/***封装的接口***/

staticAFHTTPSessionManager*session =nil;

+ (AFHTTPSessionManager*)getSessionManager {

staticdispatch_once_tonceToken;

dispatch_once(&onceToken, ^{

session= [AFHTTPSessionManagermanager];

session.requestSerializer.timeoutInterval=15;

session.responseSerializer.acceptableContentTypes=[NSSetsetWithObjects:@"application/json",@"text/json",@"text/javascript",@"text/html",@"text/plain",nil];

session.requestSerializer= [AFHTTPRequestSerializerserializer];//默认是二进制

session.responseSerializer= [AFHTTPResponseSerializerserializer];//默认是JSON

});

returnsession;

}

你可能感兴趣的:(单例对AFNetworking的封装)