How and where in the code can handle responses from the server when requests using AFNetworking? Can't find detailed and full example.
Interested in situation:
exceeded the timeout of the response (for example, 5 seconds, the server is not responding due to bad Internet)
there is no Internet at all
error in the script on the remote server
internal server error / prevention.. etc. Most of the most common causes.
I just want to show different AlertView depending on the response code from server.
Example query:
NSString * URL = @"http://supersite.ru/script.php";
NSURL * nsURL = [NSURL URLWithString:URL];
NSURLRequest *request = [NSURLRequest requestWithURL:nsURL];
AFHTTPRequestOperation *operationFeedback = [[AFHTTPRequestOperation alloc] initWithRequest:request];
operationFeedback.responseSerializer = [AFJSONResponseSerializer serializer];
[operationFeedback setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id JSONResponse){
// ... then handling the response
} failure:^(AFHTTPRequestOperation *operation, NSError *err)
{
// ... and then probably need to handle the response code?!
}];
[operationFeedback start];