[英][__NSCFNumber length]: unrecognized selector sent to instance 0x6d21350
What could this error mean?这个错误意味着什么?
[__NSCFNumber length]: unrecognized selector sent to instance 0x6d21350
Here is my code:这是我的代码:
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];
}
}
}];
I tried debuggin, and it dies once it enters the performRequestWithHandler.我试过debuggin,一进入performRequestWithHandler就死了。 It goes the else block and dies with the error above.它进入 else 块并因上述错误而死。
It means that you are passing an NSNumber
where the called code expects an NSString
or some other object that has a length
method.这意味着您正在传递一个NSNumber
,其中被调用的代码需要一个NSString
或其他一些具有length
方法的 object。 You can tell Xcode to break on exceptions so that you see where exactly the length
method gets called.您可以告诉 Xcode 在出现异常时中断,以便您看到调用length
方法的确切位置。
Specifically this line of code:具体这行代码:
[params setObject:replyToID forKey:@"in_reply_to_status_id"];
the replyToID
is not a String or has a method length
. replyToID
不是 String 或具有方法length
。 If you don't have this, or if you convert the replyToID
to a String before setting it in params it should work.如果你没有这个,或者如果你在将replyToID
设置为 params 之前将其转换为 String 它应该可以工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.