TWRequest сбой при отправке ответа - PullRequest
1 голос
/ 10 декабря 2011

Я использую TWRequest для публикации ответа в Твиттере (используя "in_reply_to_status_id"), и по какой-то причине TWRequest дает сбой.

Так что, если пользователь предоставляет responseID, тогда:

  if(replyID){
     paramDict = [NSDictionary dictionaryWithObjectsAndKeys: replyID, @"in_reply_to_status_id", tweet, @"status", nil];
}
    else
         paramDict = [NSDictionary dictionaryWithObject:tweet forKey:@"status"];

  postRequest = [[TWRequest alloc] initWithURL:
  [NSURL URLWithString:@"http://api.twitter.com/1/statuses/update.json"] 
       parameters: paramDict requestMethod:TWRequestMethodPOST];



  // Post the request
[postRequest setAccount:myAccount];

// Block handler to manage the response
[postRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) 
//                     [postRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) 


{

NSDictionary *responseDict = [NSJSONSerialization JSONObjectWithData:responseData options:kNilOptions error:&error];

                      NSLog(@"Twitter response, HTTP response: %i with Error: %@", [urlResponse statusCode], [error localizedDescription]);
                      NSLog(@"response: %@", responseDict);

                      if([urlResponse statusCode] == 200){

                          if([delegate respondsToSelector:@selector(sendTweetSuccess)]){
                              [delegate sendTweetSuccess];
                          }
                      }
                      else{

                          if([delegate respondsToSelector:@selector(sendTweetFailed:)]){
                              [delegate sendTweetFailed:error];
                          }
                      }
                  }];
}

Я получаю сбой, который указывает на это:

[postRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) 

И сбой:

-[__NSCFNumber length]: unrecognized selector sent to instance 0x160970
2011-12-10 01:55:53.553 NSTweet[4694:1903] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFNumber length]: unrecognized selector sent to instance 0x160970'
*** First throw call stack:
(0x381548bf 0x31c3a1e5 0x38157acb 0x38156945 0x380b1680 0x3809e0a9 0x380b93eb 0x380e3085 0x339a5ecd 0x339a5deb 0x339a5a79 0x339a6047 0xbe37 0x31b0dd8d 0x37e0fd55 0x37e12897 0x365771cf 0x365770a4)
terminate called throwing an exception

Это прекрасно работает, если я не предоставляю replyID.Спасибо за любую помощь.

1 Ответ

3 голосов
/ 16 декабря 2011

Похоже, вы отправляете NSNumber, но TWRequest ожидает, что все параметры будут NSString.

...