nsurlsession - iOS - Why is this method so slow? -


i have ios method deprecated --nsurlconnection sendsynchronousrequest. method worked , fast.

i must doing wrong new method, unacceptably slow.

the new method code i'm showing whole routine is:

- (void)getdata {     nslog(@"%s", __function__);      pathstring = @"https://api.wm.com/json/jroutes/.......";      nsurl *url = [nsurl urlwithstring:pathstring......];      nsurlsessiondatatask *downloadtask = [[nsurlsession sharedsession]                                           datataskwithurl:url completionhandler:^(nsdata *data, nsurlresponse *response, nserror *error) {                                                if ([response respondstoselector:@selector(statuscode)]) {                                                   if ([(nshttpurlresponse *) response statuscode] == 404) {                                                       dispatch_async(dispatch_get_main_queue(), ^{                                                           // alert                                                           nslog(@" no data");                                                           return;                                                       });                                                   }                                               }                                                // 4: handle response here                                               [self processresponseusingdata:data];                                           }];       [downloadtask resume]; }   - (void)processresponseusingdata:(nsdata*)data {     nslog(@"%s", __function__);     nserror *error = nil;     nsmutabledictionary* json = nil;      if(nil != data)     {         json = [nsjsonserialization jsonobjectwithdata:data options:nsjsonreadingmutablecontainers error:&error];     }       if (error || !json)     {         nslog(@"could not parse loaded json error:%@", error);      } else {         dispatch_async(dispatch_get_main_queue(), ^{             allroutesarray = [json valueforkey:@"routes"];             nslog(@"allroutesarray count: %lu", (unsigned long)allroutesarray.count);             [self.tableview reloaddata];          });     }  } 


Comments