0

Trying to debug AFNetworking in my application. I need to capture the time of both request and response time to get the duration.

The duration will help me to set a reasonable timeout for the GET operation. The default 60 seconds timeout is not enough.

How do I get the request and response time? Is it part of the AFHTTPRequestOperation object?

[[AFHTTPRequestOperationManager new] GET:@"http://www.example.com"
    parameters:nil
       success:^(AFHTTPRequestOperation *operation, id responseObject) {                       
           NSLog(@"startTime={} endTime={}");
       }
       failure:^(AFHTTPRequestOperation *operation, NSError *error) {
           NSLog(@"startTime={} endTime={}");
       }
];
Peter G.
  • 7,816
  • 20
  • 80
  • 154
  • 1
    Possibly already answered here https://stackoverflow.com/questions/16498244/measuring-response-time-in-afnetworking-http-get ? Basically you can use https://github.com/AFNetworking/AFNetworkActivityLogger – Christos Koninis Sep 19 '18 at 14:04
  • Simple solution, worked like a charm. – Peter G. Sep 19 '18 at 15:14

0 Answers0