首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >发布回复时TWRequest崩溃

发布回复时TWRequest崩溃
EN

Stack Overflow用户
提问于 2011-12-10 18:02:29
回答 1查看 814关注 0票数 1

我正在使用TWRequest向Twitter发布回复(使用"in_reply_to_status_id"),但由于某种原因,TWRequest崩溃了。

因此,如果用户提供了一个replyID,那么:

代码语言:javascript
复制
  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];
                          }
                      }
                  }];
}

我得到了一个崩溃,指向这一点:

代码语言:javascript
复制
[postRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) 

和崩溃:

代码语言:javascript
复制
-[__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,这可以很好地工作。谢谢你的帮助。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-12-16 11:06:11

看起来您正在发送一个NSNumber,但TWRequest要求所有参数都为NSString。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/8455732

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档