输入文本时应用程序崩溃,无法识别的选择器发送到实例 [英] App crash whenever typing in a text, unrecognized selector sent to instance

查看:19
本文介绍了输入文本时应用程序崩溃,无法识别的选择器发送到实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当我尝试在文本字段上书写时,我的应用程序都会出现这个奇怪的错误.

I got this strange error using my app to crash whenever I am trying to write on a text field.

   -[NSNull _fastCStringContents:]: unrecognized selector sent to instance 0x108e3eaf0
   *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSNull _fastCStringContents:]: unrecognized selector sent to instance 0x108e3eaf0' 

我搜索了这个问题,但我真的不明白为什么会这样?任何人都可以帮助我吗?

I searched for this problem, but I really don't understand why this happened? Could any one help me?

这是完整的错误..

  -[NSNull _fastCStringContents:]: unrecognized selector sent to instance 0x10450caf0
  *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSNull _fastCStringContents:]: unrecognized selector sent to instance 0x10450caf0'
  *** First throw call stack:
 (
  0   CoreFoundation                      0x00000001042e7e65    __exceptionPreprocess + 165
  1   libobjc.A.dylib                     0x0000000103d60deb objc_exception_throw + 48
  2   CoreFoundation                      0x00000001042f048d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
  3   CoreFoundation                      0x000000010423d90a ___forwarding___ + 970
  4   CoreFoundation                      0x000000010423d4b8 _CF_forwarding_prep_0 + 120
  5   CoreFoundation                      0x00000001042d3f23 -[NSTaggedPointerString compare:options:range:locale:] + 243
  6   Foundation                          0x00000001034d6e37 -[NSString compare:options:range:] + 29
  7   UIKit                               0x000000010497ee6f -[UIPhysicalKeyboardEvent _matchesKeyCommand:] + 303
  8   UIKit                               0x00000001048a33fd -[UIResponder _keyCommandForEvent:target:] + 364
  9   UIKit                               0x00000001048a35b2 -[UIResponder _keyCommandForEvent:target:] + 801
  10  UIKit                               0x00000001048a35b2 -[UIResponder _keyCommandForEvent:target:] + 801
  11  UIKit                               0x00000001048a35b2 -[UIResponder _keyCommandForEvent:target:] + 801
  12  UIKit                               0x00000001048a35b2 -[UIResponder _keyCommandForEvent:target:] + 801
  13  UIKit                               0x00000001048a35b2 -[UIResponder _keyCommandForEvent:target:] + 801
  14  UIKit                               0x00000001048a35b2 -[UIResponder _keyCommandForEvent:target:] + 801
  15  UIKit                               0x00000001048a35b2 -[UIResponder _keyCommandForEvent:target:] + 801
  16  UIKit                               0x00000001048a35b2 -[UIResponder _keyCommandForEvent:target:] + 801
  17  UIKit                               0x00000001048a35b2 -[UIResponder _keyCommandForEvent:target:] + 801
  18  UIKit                               0x00000001048a35b2 -[UIResponder _keyCommandForEvent:target:] + 801
  19  UIKit                               0x00000001048a35b2 -[UIResponder _keyCommandForEvent:target:] + 801
  20  UIKit                               0x00000001048a35b2 -[UIResponder _keyCommandForEvent:target:] + 801
  21  UIKit                               0x00000001048a35b2 -[UIResponder _keyCommandForEvent:target:] + 801
  22  UIKit                               0x00000001048a35b2 -[UIResponder _keyCommandForEvent:target:] + 801
  23  UIKit                               0x00000001048a35b2 -[UIResponder _keyCommandForEvent:target:] + 801
  24  UIKit                               0x00000001046b51aa -[UIApplication handleKeyHIDEvent:] + 397
  25  UIKit                               0x000000010468e838 _UIApplicationHandleEventQueue + 5469
  26  CoreFoundation                      0x0000000104213a31 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
  27  CoreFoundation                      0x000000010420995c __CFRunLoopDoSources0 + 556
  28  CoreFoundation                      0x0000000104208e13 __CFRunLoopRun + 867
  29  CoreFoundation                      0x0000000104208828 CFRunLoopRunSpecific + 488
  30  GraphicsServices                    0x0000000108449ad2 GSEventRunModal + 161
  31  UIKit                               0x0000000104694610 UIApplicationMain + 171
  32  Parents-Baby Link                   0x0000000102241dfd main + 109
  33  libdyld.dylib                       0x00000001066f292d start + 1
  34  ???                                 0x0000000000000001 0x0 + 1
 )
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

推荐答案

好吧,有一个可能适合您的解决方案,请尝试将 textfield 放在初始 viewController 中并检查应用程序是否崩溃(如果应用程序没有崩溃)打字时你试试这个:

Okay there is one solution which may work for you, please try to put the textfield in the initial viewController and check if the app crashes if app don't crash when typing you try this:

由于某种原因,我使用的标签栏控制器导致了这个问题.只需删除控制器,然后转到 Editor > Embed In > Tab Bar Controller 并重新添加视图即可修复它.参考

For some reason the tab bar controller I was using was causing the issue. Simply deleting the controller, and then going Editor > Embed In > Tab Bar Controller and re adding the views fixed it. Ref

另一个问题可能是Textfield中传递的数据格式不正确,可能为Null或字符串以外的格式无效

In the another problem can be the data which is passed in the Textfield is not in the valid format is may be Null or have invalid format other than string

这篇关于输入文本时应用程序崩溃,无法识别的选择器发送到实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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