iphoneobjective-ciosipadtwrequest

issue with EXC_BAD_REQUEST in TWRequest


I have the following code and it always gives me a crash when performing the request, any idea?

NSString *responseBody = [[NSString alloc] initWithData:data
                                                       encoding:NSUTF8StringEncoding];

        NSLog(@"Response body is %@", responseBody);

        NSDictionary *accessTokenRequestParams = [[NSMutableDictionary alloc] init];
        [accessTokenRequestParams setValue:CONSUMER_KEY forKey:@"x_reverse_auth_target"];
        [accessTokenRequestParams setValue:responseBody forKey:@"x_reverse_auth_parameters"];            

        NSURL *url2 = [NSURL URLWithString:@"https://api.twitter.com/oauth/access_token"];
        TWRequest * accessTokenRequest = [[TWRequest alloc] initWithURL:url2 parameters:accessTokenRequestParams requestMethod:TWRequestMethodPOST];


        if (selectionIndex != -1)
            [accessTokenRequest setAccount:[self.twitterACAccounts objectAtIndex:selectionIndex]];

        // execute the request
        [accessTokenRequest performRequestWithHandler:
         ^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
             NSString *responseStr = 
             [[NSString alloc] initWithData:responseData 
                                   encoding:NSUTF8StringEncoding];

            NSLog(@"The user's info for your server:\n%@", responseStr);
         }];

UPDATE: Turning on NSZombieEnabled gives me

*** -[ACAccountStore typeForAccount:]: message sent to deallocated instance 0x7199c70

this is no where to be found


Solution

  • Your error looks completely different than your question. You have error in ACAccountStore class. Check your retain count when you accessing, manipulating, and store accounts (ACAccountStore). I think you are deallocated memory first and you are using some where.