ios - AFNetworking and processing of server responses -


how , in code can handle responses server when requests using afnetworking? can't find detailed , full example.

interested in situation:

  1. exceeded timeout of response (for example, 5 seconds, server not responding due bad internet)

  2. there no internet @ all

  3. error in script on remote server

  4. internal server error / prevention.. etc. of common causes.

i want show different alertview depending on response code 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){  // ... handling response  } failure:^(afhttprequestoperation *operation, nserror *err) {  // ... , need handle response code?!  }]; [operationfeedback start]; 


Comments