Je traite le problème d'authentification avec le count Tumblr en utilisant [NSURLConnection sendAsynchronousRequest:queue:completionHandler:]
pour envoyer la request d'authentification, mais ici, je rencontre un problème difficile:
Je me request si le problème vient du NSURLConnection
.
- (void)authenticate:(NSSsortingng *)URLScheme WithViewController:(UIViewController *)con callback:(TMAuthenticationCallback)callback { self.threeLeggedOAuthTokenSecret = nil; self.hostViewController = con; self.callback = callback; [self emptyCookieJar]; NSSsortingng *tokenRequestURLSsortingng = [NSSsortingng ssortingngWithFormat:@"http://www.tumblr.com/oauth/request_token?oauth_callback=%@", TMURLEncode([NSSsortingng ssortingngWithFormat:@"%@://tumblr-authorize", URLScheme])]; NSLog(@"%@", tokenRequestURLSsortingng); NSMutableURLRequest *request = mutableRequestWithURLSsortingng(tokenRequestURLSsortingng); NSLog(@"%@", request); [[self class] signRequest:request withParameters:nil consumerKey:self.OAuthConsumerKey consumerSecret:self.OAuthConsumerSecret token:nil tokenSecret:nil]; [self openOAuthViewController]; NSURLConnectionCompletionHandler handler = ^(NSURLResponse *response, NSData *data, NSError *error) { NSInteger statusCode = ((NSHTTPURLResponse *)response).statusCode; if (error) { if (callback) { callback(nil, nil, error); } return; } NSLog(@"%d", statusCode); if (statusCode == 200) { self.threeLeggedOAuthCallback = callback; NSDictionary *responseParameters = formEncodedDataToDictionary(data); self.threeLeggedOAuthTokenSecret = responseParameters[@"oauth_token_secret"]; NSURL *authURL = [NSURL URLWithSsortingng: [NSSsortingng ssortingngWithFormat:@"http://www.tumblr.com/oauth/authorize?oauth_token=%@", responseParameters[@"oauth_token"]]]; [self initOAuthViewControllerWithURL:authURL]; } else { if (callback) { callback(nil, nil, errorWithStatusCode(statusCode)); } } }; [NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:handler]; }
Code ci-dessus, tout se passe normalement avant [NSURLConnection sendAsynchronousRequest:queue:completionHandler:]
, et après cette méthode j'ai eu l'erreur dans completionHandler
.