[__NSCFNumber length]:无法识别的选择器发送到实例0x6d21350 [英] [__NSCFNumber length]: unrecognized selector sent to instance 0x6d21350

查看:112
本文介绍了[__NSCFNumber length]:无法识别的选择器发送到实例0x6d21350的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个错误意味着什么?

[__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块并且因上述错误而死亡。

I tried debuggin, and it dies once it enters the performRequestWithHandler. It goes the else block and dies with the error above.

推荐答案

这意味着你传递的是 NSNumber 其中被调用代码需要 NSString 或其他具有长度方法的对象。您可以告诉Xcode中断异常,以便您可以看到 length 方法的确切位置。

It means that you are passing an NSNumber where the called code expects an NSString or some other object that has a length method. You can tell Xcode to break on exceptions so that you see where exactly the length method gets called.

这篇关于[__NSCFNumber length]:无法识别的选择器发送到实例0x6d21350的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆