A'FNetwork返回转化
2017-04-12 本文已影响7人
杨大虾
+ (void (^)(NSURLSessionDataTask * task, id returnData))successCallBack:(void (^)(id returnData))successBlock{
return ^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
if (!successBlock) return ;
successBlock([NSDictionary replaceNullValueDictionary:[NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers error:nil]]);
};
}
虽然AFNetwork有返回解析,但是会不准,一般是自己来解析,加多这一句
[NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers error:nil]
因为从断点可以看出
responseObject其实是Data类型,必须要转,否则不能直接用