美文网首页
iOS打印AFNetworking中Error错误信息

iOS打印AFNetworking中Error错误信息

作者: 尕歪Tia | 来源:发表于2018-11-15 17:34 被阅读21次

    [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错误信息

          本文链接:https://www.haomeiwen.com/subject/xttufqtx.html