:发送到实例0x6d21350的无法识别的select器

这个错误是什么意思?

[__NSCFNumber length]: unrecognized selector sent to instance 0x6d21350 

这是我的代码:

  NSString *urlString = @"http://api.twitter.com/1/statuses/update.json"; NSURL *url = [NSURL URLWithString:urlString]; NSMutableDictionary *params = [[NSMutableDictionary alloc] init]; [params setObject:status forKey:@"status"]; [params setObject:replyToID forKey:@"in_reply_to_status_id"]; [params setObject:@"1" forKey:@"include_entities"]; // Build the request with our parameter TWRequest *request = [[TWRequest alloc] initWithURL:url parameters:params requestMethod:TWRequestMethodPOST]; // Attach the account object to this request [request setAccount:twitterAccount]; [request performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) { if (!responseData) { // inspect the contents of error NSLog(@"%@", [error localizedDescription]); self.alert = [[UIAlertView alloc] initWithTitle:@"HTTP error" message:@"I could not connect to the Twitter API." delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil]; [self.alert show]; [self.replyDelegate replyRequestSuccessful:NO]; } else { /*NSString *responseDataAsString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding]; NSLog(responseDataAsString);*/ NSError *error; NSArray *replyResponse = [NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingMutableLeaves error:&error]; if (!replyResponse) { NSLog(@"%@", [error localizedDescription]); self.alert = [[UIAlertView alloc] initWithTitle:@"JSON error" message:@"I could not parse the JSON response from the Twitter API." delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil]; [self.alert show]; [self.replyDelegate replyRequestSuccessful:NO]; } else { [self.replyDelegate replyRequestSuccessful:YES]; } } }]; 

我试过debuggin,一旦进入performRequestWithHandler就死了。 它去了else块,并与上面的错误死亡。

这意味着你正在传递一个NSNumber ,其中被调用的代码需要一个NSString或者其他一些具有length方法的对象。 你可以告诉Xcode打破exception,以便你看到length方法被调用的地方。

具体来说这行代码:

 [params setObject:replyToID forKey:@"in_reply_to_status_id"]; 

replyToID不是一个string或有一个方法length 。 如果你没有这个,或者如果你将replyToID转换为一个string,然后将其设置为参数,它应该工作。