简体   繁体   English

[__NSCFNumber 长度]:无法识别的选择器发送到实例 0x6d21350

[英][__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.

相关问题 [__NSCFNumber长度]:无法识别的选择器已发送到实例 - [__NSCFNumber length]: unrecognized selector sent to instance [__NSCFNumber isEqualToString:]:无法识别的选择器已发送到实例 - [__NSCFNumber isEqualToString:]: unrecognized selector sent to instance [NSCFNumber _isNaturallyRTL]:无法识别的选择器发送到实例0x605ac10 - [NSCFNumber _isNaturallyRTL]: unrecognized selector sent to instance 0x605ac10 -[__ NSArrayM length]:无法识别的选择器已发送到实例0x145ecca0 - -[__NSArrayM length]: unrecognized selector sent to instance 0x145ecca0 'NSInvalidArgumentException':无法识别的选择器发送到实例0x8d25aa0' - 'NSInvalidArgumentException': unrecognized selector sent to instance 0x8d25aa0' [UIView setText:]:无法识别的选择器已发送到实例0x89625d0 - [UIView setText:]: unrecognized selector sent to instance 0x89625d0 ViewController长度无法识别的选择器已发送到iPhone中的实例 - Viewcontroller length unrecognized selector sent to instance in iphone 无法识别的选择器已发送到实例0x6b61d10 - unrecognized selector sent to instance 0x6b61d10 NSCFString objectAtIndex无法识别的选择器已发送到实例0x5d52d70 - NSCFString objectAtIndex unrecognized selector sent to instance 0x5d52d70 无法识别的选择器发送到实例 - unrecognized selector sent to instance
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM