I'm trying to send a HTTP request with NSURLSession
. It works fine, but when the server doesn't respond I can't find where the HTTP error code is stored. The third parameter of completionHandler
is just a very general NSError
. I read the reference of NSURLResponse
but found nothing.
NSURLSessionDataTask *dataTask =
[session dataTaskWithRequest:[self postRequestWithURLString:apiEntry parameters:parameters]
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if(!error) NSLog([[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]);
}
];
[dataTask resume];