[manager POST:URLString parameters:parameters success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
if (success) {
NSString *resString = [[NSString alloc]initWithData:responseObject encoding:NSUTF8StringEncoding];
success(resString);
}
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
if (error) {
NSData *responseData = error.userInfo[AFNetworkingOperationFailingURLResponseDataErrorKey];
NSString * receive = [[NSString alloc]initWithData:responseData encoding:NSUTF8StringEncoding];
//字符串再生成NSData
NSData *data = [receive dataUsingEncoding:NSUTF8StringEncoding];
NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:nil];
}
}];
网友评论