微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

iphone – [__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块并且死于上面的错误

解决方法

这意味着您正在传递一个NSNumber,其中被调用代码期望Nsstring或其他具有长度方法的对象。您可以告诉Xcode打破异常,以便您可以看到长度方法调用的位置。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐