AFNetworking Domain=com.alamofire.error.serialization.response Code=-1016

使用AF时,网络请求报错:Domain=com.alamofire.error.serialization.response Code=-1016

AFHTTPResponseSerializer.m --> AFJSONResponseSerializer
AFNetworking Domain=com.alamofire.error.serialization.response Code=-1016_第1张图片

设置manager.requestSerializer = [AFHTTPRequestSerializer serializer];

+ (AFHTTPSessionManager *)sharedManager {
    static AFHTTPSessionManager *manager = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        manager = [AFHTTPSessionManager manager];
        manager.requestSerializer = [AFHTTPRequestSerializer serializer];
        manager.requestSerializer.timeoutInterval = 10;
    });
    return manager;
}


manager.responseSerializer = [[AFHTTPResponseSerializer alloc] init];

NSString *jsonStr = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
NSDictionary *result = [AZTool jsonStringToDictionary:jsonStr];

在AF里添加acceptableContentType的话不太好。

你可能感兴趣的:(#,error,&,warning)