lundi 11 juillet 2016

when i'm dong ( AFNetworking 3.1) web request,how can i analyze failure task


[manager POST:url parameters:params progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) { success(task, responseObject);

   } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
       NSHTTPURLResponse* httpResponse = (NSHTTPURLResponse*)task.response;
       NSInteger responseStatusCode = [httpResponse statusCode];

       NSString *responseText=task.response.description;
        // NSString *responseText = operation.responseString;
        NSData* data=[responseText dataUsingEncoding:NSUTF8StringEncoding];
        NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
        failure(dict ,responseStatusCode);

    }];

My server come back failuer code,how can i get it?


Aucun commentaire:

Enregistrer un commentaire