草庐IT

iphone - [__NSCFNumber 长度] : unrecognized selector sent to instance 0x6d21350

coder 2023-07-25 原文

这个错误意味着什么?

[__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 block 并因上述错误而终止。

最佳答案

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

关于iphone - [__NSCFNumber 长度] : unrecognized selector sent to instance 0x6d21350,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10095459/

有关iphone - [__NSCFNumber 长度] : unrecognized selector sent to instance 0x6d21350的更多相关文章

  1. 电脑0x0000001A蓝屏错误怎么U盘重装系统教学 - 2

      电脑0x0000001A蓝屏错误怎么U盘重装系统教学分享。有用户电脑开机之后遇到了系统蓝屏的情况。系统蓝屏问题很多时候都是系统bug,只有通过重装系统来进行解决。那么蓝屏问题如何通过U盘重装新系统来解决呢?来看看以下的详细操作方法教学吧。  准备工作:  1、U盘一个(尽量使用8G以上的U盘)。  2、一台正常联网可使用的电脑。  3、ghost或ISO系统镜像文件(Win10系统下载_Win10专业版_windows10正式版下载-系统之家)。  4、在本页面下载U盘启动盘制作工具:系统之家U盘启动工具。  U盘启动盘制作步骤:  注意:制作期间,U盘会被格式化,因此U盘中的重要文件请注

  2. ruby-on-rails - 如何解决#<Book::ActiveRecord_Relation:0x007fb709a6a8c0> 的未定义方法 `to_key'? - 2

    我遇到了未定义方法`to_key'的问题这是我的books_controller.rbclassBooksController和我的索引页如下。index.html.erb......现在当我要访问索引页面时出现如下错误。undefinedmethod`to_key'for# 最佳答案 index通常返回一个集合。事实上,您的Controller符合要求。但是,您的View试图为其定义一个表单。正如您所发现的,这不会成功。表单适用于实体,而不适用于集合。该错误在您看来以及您希望如何处理index。

  3. ruby-on-rails - Rspec - Controller 测试错误 - Paperclip::AdapterRegistry::NoHandlerError: 找不到 "#<File:0x531beb0>"的处理程序 - 2

    我如下询问了我的Rspec测试。Rspec-RuntimeError:Calledidfornil,whichwouldmistakenlybe4在相同的代码上(“items_controller.rb”的Rspec测试),我试图对“PUTupdate”进行测试。但是我收到错误消息“Paperclip::AdapterRegistry::NoHandlerError:找不到“#”的处理程序。我的Rspec测试如下。老实说,我猜这次失败的原因是“let(:valid_attributes)”上的“photo”=>File.new(Rails.root+'app/assets/images

  4. ruby-on-rails - `method_missing':#<Rails::Application::Configuration:0x00> 的未定义方法 `action_mailer' - 2

    我正在构建一个Rails应用程序并且使用的是Rails4.0.1。我有一个错误,并注意到它在3个月前被称为rails上的一个错误,所以我决定:捆绑更新并获得rails4.0.3这样做之后,测试和服务器都不会启动,并且会抛出错误:gems/railties-4.0.3/lib/rails/railtie/configuration.rb:95:in`method_missing':undefinedmethod`action_mailer'for#(NoMethodError)目前我在config/environments/*中注释掉了action_mailer行,但最好能找到一个真正的

  5. ruby-on-rails - #<ProjectsController :0x007faead1853e0> 的未定义方法 `user_signed_in?' - 2

    我想用RubyonRails进行身份验证,每个用户都有自己的帐户。但是现在我得到了这个错误:undefinedmethoduser_signed_in?for#有人能帮帮我吗?代码如下:完整跟踪:app/controllers/projects_controller.rb:69:in`require_login'activesupport(3.2.3)lib/active_support/callbacks.rb:418:in`_run__2505248868868045404__process_action__114470166732456289__callbacks'actives

  6. iphone - 扩展 restful_authentication/AuthLogic 以支持匿名 iPhone 的延迟登录的最佳方法是什么? - 2

    我正在构建一个与RubyonRails后端对话的iPhone应用程序。RubyonRails应用程序还将为Web用户提供服务。restful_authentication插件是提供快速和可定制的用户身份验证的绝佳方式。但是,我希望iPhone应用程序的用户在新列中存储一个由手机的唯一标识符([[UIDevicedevice]uniqueIdentifier])自动创建的帐户。稍后,当用户准备好创建用户名/密码时,帐户将更新为包含用户名和密码,iPhone唯一标识符保持不变。用户在设置用户名/密码之前不能访问该网站。然而,他们可以使用iPhone应用程序,因为该应用程序可以使用它的标识符

  7. iphone - 设计和 Rails 3 中的 http 身份验证 - 2

    我有一个使用deviseonrails3的应用程序。我想启用http身份验证,以便我可以从iPhone应用程序向我的网络应用程序进行身份验证。如何从我的iPhone应用程序进行身份验证以进行设计?这安全吗?还是我应该进行不同的身份验证? 最佳答案 从设计的角度来看,您有3个选择:1)使用基本的http身份验证:您的iPhone应用程序有一个secretkey-这是在您的iPhone应用程序代码中烘焙的-用于对网络应用程序的每个请求进行身份验证。Google搜索:“设计基本的http身份验证”2)您可以通过在您的iPhone应用程序中

  8. ruby - bundle install 为 #<Bundler::Dsl:0x00000001c4e1f8> 提供未定义的方法 `ruby' - 2

    bundleinstall给出:>undefinedmethod`ruby'for#知道如何解决吗?我使用的是Ruby1.9.3-p125。 最佳答案 Gembundler的1.2版介绍了一个rubymethodtothedsl允许您指定您的应用程序应使用的Ruby版本。看起来您使用的Gemfile是为这个新版本编写的,但是您的bundler版本不支持ruby方法。您需要安装最新的bundler(geminstallbundler应该这样做)或从您的Gemfile中删除该行。 关于rub

  9. ruby - #<Hash :0x3d3cef0> (NoMethodError) in ActiveSupport 3 的未定义方法 `to_json' - 2

    to_json是否被删除了? 最佳答案 尝试添加require"active_support/core_ext"require'active_support'不会自行将行为注入(inject)核心类。这样你就可以选择你想要的扩展。使用core_ext将您熟悉的扩展从rails转储到核心类中。 关于ruby-#(NoMethodError)inActiveSupport3的未定义方法`to_json',我们在StackOverflow上找到一个类似的问题: ht

  10. #<Hash :0x2954fe8> 的 Ruby 未定义方法 `bytesize' - 2

    我有以下Ruby代码,用于沙盒模式下的跟踪网站:require"net/http"require"net/https"require"uri"xml=XMLuri=URI('https://cig.dhl.de/services/sandbox/rest/sendungsverfolgung')nhttp=Net::HTTP.new(uri.host,uri.port)nhttp.use_ssl=truenhttp.verify_mode=OpenSSL::SSL::VERIFY_NONErequest=Net::HTTP::Get.new(uri)request.basic_auth

随机推荐