ios - NSURLSession performSegueWithIdentifier not running -
i have next code unsure why not running:
nsurlsession *session = [nsurlsession sharedsession]; nsurlsessiondatatask *datatask = [session datataskwithurl: [nsurl urlwithstring:myurlstring] completionhandler:^ (nsdata *data, nsurlresponse *response, nserror *error) {nsdictionary *json = [nsjsonserialization jsonobjectwithdata:data options:0 error:nil]; [self performseguewithidentifier:@"login" sender:self];}]; [datatask resume];
the preformseguewithidentifier works outside not within brackets. have done similar using nsurlconnection , works fine. i'm new nsurlsession ideas why performseguewithidentifier doesn't run within call.
any ideas?
if create nsurlsession object way are, creates new serial operation queue not main queue. completion handler of datataskwithurl: method run on session's queue, it's not working because you're trying ui task on background queue. prepare it, create session this,
nsurlsession *session = [nsurlsession sessionwithconfiguration:[nsurlsessionconfiguration defaultsessionconfiguration] delegate: nil delegatequeue: [nsoperationqueue mainqueue]];
ios segue nsurlsession
No comments:
Post a Comment