iOS打印AFNetworking中Error错误信息

[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];
        }
    }];

你可能感兴趣的:(iOS打印AFNetworking中Error错误信息)