简体   繁体   English

为什么我得到一个“无法识别的选择器发送到实例”错误?

[英]Why am I getting a `unrecognized selector sent to instance` error?

I have a Ruby on Rails application that has an API, it's an OAuth 2.0 provider and uses Doorkeeper. 我有一个带有API的Ruby on Rails应用程序,它是一个OAuth 2.0提供程序并使用Doorkeeper。 I am creating an iPhone client for that application and am using the gtm-oauth2 library for authentication. 我正在为该应用程序创建一个iPhone客户端,并使用gtm-oauth2库进行身份验证。 Here is the Github repository for the iPhone app. 这是iPhone应用程序的Github存储库

I manage do the authentication request using the library and get the response from the OAuth server, but (I think that) when the iPhone app receives the response, the iPhone app crashes. 我管理使用库执行身份验证请求并从OAuth服务器获取响应,但(我认为)当iPhone应用程序收到响应时,iPhone应用程序崩溃。 I get the following error: 我收到以下错误:

2013-03-25 07:30:51.563 Catapult for iOS[68917:c07] -[NSNull length]: unrecognized selector sent to instance 0x14f2678
2013-03-25 07:30:51.564 Catapult for iOS[68917:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSNull length]: unrecognized selector sent to instance 0x14f2678'
*** First throw call stack:
(0x13c1012 0x11e6e7e 0x144c4bd 0x13b0bbc 0x13b094e 0xf074 0x185e3 0x13b51bd 0x13b50d6 0x1531a 0x1512b 0x14ae2 0x13b51bd 0x13b50d6 0x11d0a 0x1032a 0x13b51bd 0x13b50d6 0x79be 0x77ed 0x8cf2 0xcec589 0xcea652 0xceb89a 0xcea60d 0xcea785 0xc37a68 0x4a2a911 0x4a29bb3 0x4a67cda 0x13638fd 0x4a6835c 0x4a682d5 0x4952250 0x1344f3f 0x1344a39 0x1367734 0x1366f44 0x1366e1b 0x22be7e3 0x22be668 0x12affc 0x2c6d 0x2b95)
libc++abi.dylib: terminate called throwing an exception

I am a complete noob/beginner when it comes to iOS development and Objective-C programming, and I am learning how to create my first app using this little project. 在iOS开发和Objective-C编程方面,我是一个完整的菜鸟/初学者,我正在学习如何使用这个小项目创建我的第一个应用程序。 I asked the same question in the gtm-oaut2 Google Group and according to them, the problem comes from my code and not the library. 我在gtm-oaut2 Google Group中提出了同样的问题,根据他们的说法,问题来自我的代码而不是库。 The problem is that all of my code is taken from their wiki and I can't pinpoint where the app crashes. 问题是我的所有代码都是从他们的wiki中获取的,我无法确定应用程序崩溃的位置。 If I understand correctly, at some point I am calling length of NSNull, but I am not calling length anywhere, hence my confusion. 如果我理解正确,在某些时候我会调用NSNull的length ,但我不是在任何地方调用length ,因此我的困惑。 Also, when the app crashes, the line hilighted is in the main.m file and the error (on the right label, not in the output) is the following: 此外,当应用程序崩溃时,行正常显示在main.m文件中,错误(在右侧标签上,而不在输出中)如下:

Thread 1: signal SIGABRT

I have no clue what that means... 我不知道这意味着什么......

Does anyone know what the problem might be please? 有谁知道问题可能是什么?

You're right that the issue is that somewhere you've got the length message being sent to an instance of NSNull . 你是对的,问题是你已经将length消息发送到NSNull一个实例。 To pinpoint where exactly this is happening set a breakpoint on objc_exception_throw. 要确定究竟发生了什么,请在objc_exception_throw上设置断点。 You can do this in the Xcode UI with little "+" button in the bottom left corner on the breakpoints tab. 您可以在Xcode UI中使用断点选项卡左下角的“+”按钮执行此操作。 Select "Add Exception breakpoint." 选择“添加异常断点”。 Then the debugger will stop your program at the point where the error occurs instead of waiting for the program to actually crash. 然后调试器将在发生错误的位置停止程序,而不是等待程序实际崩溃。

Well... you understood the error correctly.. You are somewhere calling length on a NSNull instance. 嗯...你正确地理解了错误..你在NSNull实例上调用长度。

I must find out where this is happening. 我必须找出这发生的地方。 I think this is happening in a JSON response. 我认为这是在JSON响应中发生的。 Maybe you (or "the code") is calling length on something it expects its a NSString but it is instead NSNull (that is the json has a NULL value). 也许你(或“代码”)在它期望它的NSString东西上调用长度,但它是NSNull (即json具有NULL值)。 Try if you manage to print the json response and see if you found a key mapped to a null value... 如果您设法打印json响应并查看是否找到映射到空值的键,请尝试...

NSNull does not respond to length NSNull没有响应长度

You can check the documentation for NSNull to see that this is the case. 您可以查看NSNull的文档 ,看看是否是这种情况。

Without having an idea of what your code base is doing I am not sure where to look, you must be calling [NSNull null]; 如果不知道你的代码库在做什么,我不知道在哪里看,你必须调用[NSNull null]; at some point to get the NSNull object or you are using a framework somewhere that returns this. 在某些时候获取NSNull对象或者您正在使用某个返回此框架的框架。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么我收到CIFilter的“无法识别的选择器发送给类”错误? - Why am I getting an “unrecognized selector sent to class” error for CIFilter? 为什么我会收到“ [__NSArrayI allKeys]:无法识别的选择器发送到实例” /为什么要进行NSDictionary转换? - Why am I getting “[__NSArrayI allKeys]: unrecognized selector sent to instance” / why is NSDictionary transforming? 为什么我的MapViewController收到无法识别的选择器发送到实例异常? (iOS) - Why am I getting a unrecognized selector sent to instance exception with my MapViewController? (iOS) 为什么我会收到发送到 class 的无法识别的选择器? - Why am I getting unrecognized selector sent to class? 选择器语法:为什么我得到无法识别的选择器错误? - selector syntax: why I am getting unrecognized selector error? 我认为我在分配segmentcontrol时犯了一些错误。我遇到了一个错误[无法识别的选择器发送到实例] - I think i have done some mistake in allocating segmentcontrol..i am getting an error [unrecognized selector sent to instance] 无法识别的选择器发送到实例 - 为什么? - Unrecognized selector sent to instance - why? 为什么无法识别的选择器被发送到实例? - Why Unrecognized selector sent to instance? 定义方法后,为什么会收到“无法识别的选择器发送到实例”错误? - Why am I getting an “unrecognised selector sent to instance” error when I have defined the method? 错误:无法识别的选择器发送到实例 - Error: unrecognized selector sent to instance
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM