ios - UIAlertView takes too long when using inside NSURLSession -


i using nsurlsession information server. after data, show in uialertview, takes long show. print data nslog , prints instantly... happening? method datataskwithrequest not asynchronous? why takes time pop alert view?

nsurlsession *session; session = [nsurlsession sharedsession]; nsurl * url = [nsurl urlwithstring:[dressable_ip stringbyappendingstring:@"index.php"]]; nsmutableurlrequest * urlrequest = [[nsmutableurlrequest alloc] initwithurl:url cachepolicy:connection_cachepolicy  timeoutinterval:connection_timeout]; [urlrequest sethttpmethod:@"post"]; nsurlsessiondatatask *datatask = [session datataskwithrequest:urlrequest  completionhandler:^(nsdata *data, nsurlresponse *response, nserror *error) {         nsstring *total = [[nsstring alloc]initwithdata:data encoding:nsutf8stringencoding];         [[[uialertview alloc] initwithtitle:@"title" message:total delegate:self cancelbuttontitle:@"ok" otherbuttontitles:nil] show];  }]; 

all ui activity must done in main queue.

nsurlsession *session; session = [nsurlsession sharedsession]; nsurl * url = [nsurl urlwithstring:[dressable_ip stringbyappendingstring:@"index.php"]]; nsmutableurlrequest * urlrequest = [[nsmutableurlrequest alloc] initwithurl:url cachepolicy:connection_cachepolicy  timeoutinterval:connection_timeout]; [urlrequest sethttpmethod:@"post"]; nsurlsessiondatatask *datatask = [session datataskwithrequest:urlrequest  completionhandler:^(nsdata *data, nsurlresponse *response, nserror *error) {         nsstring *total = [[nsstring alloc]initwithdata:data encoding:nsutf8stringencoding]; dispatch_async(dispatch_get_main_queue(),^{         [[[uialertview alloc] initwithtitle:@"title" message:total delegate:self cancelbuttontitle:@"ok" otherbuttontitles:nil] show]; });  }]; 

Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -