[NSNull 长度]:无法识别的选择器发送到键盘击键实例? [英] [NSNull length]: unrecognized selector sent to instance on keyboard keystroke?

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

问题描述

我在静态表视图上添加了一些 textFieldtextView.代码很好,可以在 xcode 6.4/ios 8. * 上运行,但它抛出了我无法跟踪的异常.现在我正在 xcode 7.2 (swift2.2) 上调试代码

I have added some textField and textView on static table view. the code was fine and running on xcode 6.4 / ios 8. * but it is throwing exception which i am not able to track. now i am debugging code on xcode 7.2 (swift2.2)

我也尝试放置符号特殊断点,但没有运气:(

I tried putting symbolic and and exceptional break point too but no luck :(

以下是崩溃的堆栈跟踪,在此先感谢您的宝贵帮助.

following is stack trace of crash, Thanks in advance for your valuable help.

2015-12-14 16:07:07.989 TuteMate[3380:90711] -[NSNull length]: unrecognized selector sent to instance 0x10ccc6af0 

来自异常断点:

CoreFoundation`-[NSObject(NSObject) doesNotRecognizeSelector:]:
->  0x10504e3c0 <+0>:   pushq  %rbp
    0x10504e3c1 <+1>:   movq   %rsp, %rbp
    0x10504e3c4 <+4>:   pushq  %r15
    0x10504e3c6 <+6>:   pushq  %r14
    0x10504e3c8 <+8>:   pushq  %rbx
    0x10504e3c9 <+9>:   pushq  %rax
    0x10504e3ca <+10>:  movq   %rdx, %r14
    0x10504e3cd <+13>:  movq   %rdi, %rbx
    0x10504e3d0 <+16>:  movq   0x216c79(%rip), %rsi      ; "class"
    0x10504e3d7 <+23>:  callq  *0x229e1b(%rip)           ; (void *)0x000000010730b800: objc_msgSend
    0x10504e3dd <+29>:  movq   %rax, %rdi
    0x10504e3e0 <+32>:  movq   %rbx, %rsi
    0x10504e3e3 <+35>:  movq   %r14, %rdx
    0x10504e3e6 <+38>:  callq  0x10504ed00               ; __CFFullMethodName
    0x10504e3eb <+43>:  movq   %rax, %r14
    0x10504e3ee <+46>:  leaq   0x23fdeb(%rip), %r15      ; @"%@: unrecognized selector sent to instance %p"
    0x10504e3f5 <+53>:  movl   $0x3, %edi
    0x10504e3fa <+58>:  xorl   %eax, %eax
    0x10504e3fc <+60>:  movq   %r15, %rsi
    0x10504e3ff <+63>:  movq   %r14, %rdx
    0x10504e402 <+66>:  movq   %rbx, %rcx
    0x10504e405 <+69>:  callq  0x104fe2560               ; CFLog
    0x10504e40a <+74>:  leaq   0x22b90f(%rip), %rax      ; kCFAllocatorSystemDefault
    0x10504e411 <+81>:  movq   (%rax), %rdi
    0x10504e414 <+84>:  xorl   %esi, %esi
    0x10504e416 <+86>:  xorl   %eax, %eax
    0x10504e418 <+88>:  movq   %r15, %rdx
    0x10504e41b <+91>:  movq   %r14, %rcx
    0x10504e41e <+94>:  movq   %rbx, %r8
    0x10504e421 <+97>:  callq  0x104f35190               ; CFStringCreateWithFormat
    0x10504e426 <+102>: movq   %rax, %rdi
    0x10504e429 <+105>: callq  0x104f33580               ; CFMakeCollectable
    0x10504e42e <+110>: movq   %rax, %rbx
    0x10504e431 <+113>: movq   %rbx, %rdi
    0x10504e434 <+116>: nop    
    0x10504e435 <+117>: nopl   (%rax)
    0x10504e439 <+121>: leaq   0x225300(%rip), %rax      ; __CFOASafe
    0x10504e440 <+128>: cmpb   $0x0, (%rax)
    0x10504e443 <+131>: je     0x10504e459               ; <+153>
    0x10504e445 <+133>: movl   $0x3, %edi
    0x10504e44a <+138>: xorl   %edx, %edx
    0x10504e44c <+140>: xorl   %ecx, %ecx
    0x10504e44e <+142>: xorl   %r8d, %r8d
    0x10504e451 <+145>: movq   %rbx, %rsi
    0x10504e454 <+148>: callq  0x10501b150               ; __CFRecordAllocationEvent
    0x10504e459 <+153>: movq   %rbx, %rdi
    0x10504e45c <+156>: callq  0x1050a3696               ; symbol stub for: _objc_rootAutorelease
    0x10504e461 <+161>: movq   0x218370(%rip), %rdi      ; (void *)0x00000001052690d0: NSException
    0x10504e468 <+168>: leaq   0x234fb1(%rip), %rcx      ; NSInvalidArgumentException
    0x10504e46f <+175>: movq   (%rcx), %rdx
    0x10504e472 <+178>: movq   0x216c4f(%rip), %rsi      ; "exceptionWithName:reason:userInfo:"
    0x10504e479 <+185>: xorl   %r8d, %r8d
    0x10504e47c <+188>: movq   %rax, %rcx
    0x10504e47f <+191>: callq  *0x229d73(%rip)           ; (void *)0x000000010730b800: objc_msgSend
    0x10504e485 <+197>: movq   %rax, %rdi
    0x10504e488 <+200>: callq  0x1050a3738               ; symbol stub for: objc_exception_throw
    0x10504e48d <+205>: nopl   (%rax)

更新堆栈跟踪

2015-12-14 16:45:58.932 TuteMate[4000:109943] -[NSNull length]: unrecognized selector sent to instance 0x105b72af0
2015-12-14 16:46:02.651 TuteMate[4000:109943] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSNull length]: unrecognized selector sent to instance 0x105b72af0'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010594de65 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x0000000107bfddeb objc_exception_throw + 48
    2   CoreFoundation                      0x000000010595648d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
    3   CoreFoundation                      0x00000001058a390a ___forwarding___ + 970
    4   CoreFoundation                      0x00000001058a34b8 _CF_forwarding_prep_0 + 120
    5   CoreFoundation                      0x0000000105825dfa CFStringCompareWithOptionsAndLocale + 202
    6   Foundation                          0x0000000106019e37 -[NSString compare:options:range:] + 29
    7   UIKit                               0x00000001069c4e6f -[UIPhysicalKeyboardEvent _matchesKeyCommand:] + 303
    8   UIKit                               0x00000001068e93fd -[UIResponder _keyCommandForEvent:target:] + 364
    9   UIKit                               0x00000001068e95b2 -[UIResponder _keyCommandForEvent:target:] + 801
    10  UIKit                               0x00000001068e95b2 -[UIResponder _keyCommandForEvent:target:] + 801
    11  UIKit                               0x00000001068e95b2 -[UIResponder _keyCommandForEvent:target:] + 801
    12  UIKit                               0x00000001068e95b2 -[UIResponder _keyCommandForEvent:target:] + 801
    13  UIKit                               0x00000001068e95b2 -[UIResponder _keyCommandForEvent:target:] + 801
    14  UIKit                               0x00000001068e95b2 -[UIResponder _keyCommandForEvent:target:] + 801
    15  UIKit                               0x00000001066fb91a -[UIApplication _handleKeyUIEvent:] + 948
    16  UIKit                               0x00000001068e9e53 -[UIResponder _handleKeyUIEvent:] + 79
    17  UIKit                               0x00000001068e9e53 -[UIResponder _handleKeyUIEvent:] + 79
    18  UIKit                               0x00000001068e9e53 -[UIResponder _handleKeyUIEvent:] + 79
    19  UIKit                               0x00000001068e9e53 -[UIResponder _handleKeyUIEvent:] + 79
    20  UIKit                               0x00000001068e9e53 -[UIResponder _handleKeyUIEvent:] + 79
    21  UIKit                               0x00000001068e9e53 -[UIResponder _handleKeyUIEvent:] + 79
    22  UIKit                               0x00000001068e9e53 -[UIResponder _handleKeyUIEvent:] + 79
    23  UIKit                               0x00000001068e9e53 -[UIResponder _handleKeyUIEvent:] + 79
    24  UIKit                               0x00000001068e9e53 -[UIResponder _handleKeyUIEvent:] + 79
    25  UIKit                               0x00000001068e9e53 -[UIResponder _handleKeyUIEvent:] + 79
    26  UIKit                               0x00000001068e9e53 -[UIResponder _handleKeyUIEvent:] + 79
    27  UIKit                               0x00000001068e9e53 -[UIResponder _handleKeyUIEvent:] + 79
    28  UIKit                               0x00000001068e9e53 -[UIResponder _handleKeyUIEvent:] + 79
    29  UIKit                               0x00000001068e9e53 -[UIResponder _handleKeyUIEvent:] + 79
    30  UIKit                               0x00000001068e9e53 -[UIResponder _handleKeyUIEvent:] + 79
    31  UIKit                               0x00000001068e9e53 -[UIResponder _handleKeyUIEvent:] + 79
    32  UIKit                               0x00000001066fb2cd -[UIApplication handleKeyUIEvent:] + 79
    33  UIKit                               0x0000000106991c83 -[UIKeyboardImpl _handleKeyEvent:executionContext:] + 66
    34  UIKit                               0x0000000106b91cde -[UIKeyboardLayoutStar completeRetestForTouchUp:timestamp:interval:executionContext:] + 3356
    35  UIKit                               0x00000001069a0bbd __28-[UIKeyboardLayout touchUp:]_block_invoke + 228
    36  UIKit                               0x00000001070ed724 -[UIKeyboardTaskQueue continueExecutionOnMainThread] + 332
    37  UIKit                               0x00000001069a0ace -[UIKeyboardLayout touchUp:] + 236
    38  UIKit                               0x00000001069a1614 -[UIKeyboardLayout touchesEnded:withEvent:] + 348
    39  UIKit                               0x000000010674b49b -[UIWindow _sendTouchesForEvent:] + 835
    40  UIKit                               0x000000010674c1d0 -[UIWindow sendEvent:] + 865
    41  UIKit                               0x00000001066fab66 -[UIApplication sendEvent:] + 263
    42  UIKit                               0x00000001066d4d97 _UIApplicationHandleEventQueue + 6844
    43  CoreFoundation                      0x0000000105879a31 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    44  CoreFoundation                      0x000000010586f95c __CFRunLoopDoSources0 + 556
    45  CoreFoundation                      0x000000010586ee13 __CFRunLoopRun + 867
    46  CoreFoundation                      0x000000010586e828 CFRunLoopRunSpecific + 488
    47  GraphicsServices                    0x000000010c9daad2 GSEventRunModal + 161
    48  UIKit                               0x00000001066da610 UIApplicationMain + 171
    49  TuteMate                            0x000000010500128d main + 109
    50  libdyld.dylib                       0x000000010932c92d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException 

更新没有实现其他 viewWillAppeaer、didAppear... 方法!

UPDATE There are no other viewWillAppeaer, didAppear... methods implemented!

override func viewDidLoad() {
            super.viewDidLoad()
            title = "Profile Edit"
           }

表 viewDelegates 是

And table viewDelegates are

override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
    // #warning Potentially incomplete method implementation.
    // Return the number of sections.
    return 1
}

override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    // #warning Incomplete method implementation.
    // Return the number of rows in the section.
    return 3
}

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    let cell = super.tableView(tableView, cellForRowAtIndexPath: indexPath)
    return cell
}

推荐答案

@dip:从你的评论看来,你需要学习一些关于调试的非常重要的东西,那就是:你相信的一切都是假的强>.当您说我不存储 null 或类似内容"时,我们知道这是错误的.第二个最重要的规则:相信证据.

@dip: From your comments it seems that you need to learn something very important about debugging, and that is: Everything you believe is false. When you say "I don't store null or anything like that", we know that is false. And the second most important rule: Trust the evidence.

证据是一条消息length:"是一个 NSString 方法被发送到 [NSNull null].在您应该存储字符串的地方存储 [NSNull null].调试的第三条规则:做错了什么.没有神秘的小精灵试图让你不安,是你的代码错了.因此,找出您存储 [NSNull null] 的位置.来自 JSON 解析器的任何内容总是一个很好的候选者.

The evidence is that a message "length:" which is an NSString method is sent to [NSNull null]. Somewhere you are storing [NSNull null] where you should store a string. Third rule of debugging: You did something wrong. There are no mysterious gremlins trying to upset you, it's your code that's wrong. So find out where you are storing an [NSNull null]. Anything coming from a JSON parser is always a good candidate.

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

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