ios - [NSNull 长度] : unrecognized selector sent to instance on keyboard keystroke?

标签 ios swift tableview unrecognized-selector

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

我也尝试放置symbolicexceptional 断点,但没有成功 :(

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

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... 方法实现!

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

和表viewDelegates是

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 或类似的东西”时,我们知道那是错误的。第二条最重要的规则:相信证据

证据是消息“length:”是一个 NSString 方法被发送到 [NSNull null]。在你应该存储字符串的地方存储 [NSNull null] 。第三条调试规则:做错了什么。没有神秘的小 Sprite 试图打扰您,是您的代码出了问题。所以找出你存储 [NSNull null] 的位置。来自 JSON 解析器的任何东西总是一个很好的候选者。

关于ios - [NSNull 长度] : unrecognized selector sent to instance on keyboard keystroke?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34264796/

相关文章:

ios - 如何使用嵌套数组搜索自定义对象的 NSArray?

ios - Swift:按下按钮时编辑标签的值

Swift - 在两个 TableView (2 个 View Controller )之间传递数据

JavaFX 使用 CellFactory 将图像放入 TableView

ios - AWS DynamoDB 为用户记住项目

ios - 如何从 PFUser 缓存 PFFile

ios - 根据每个单元格的内容动态调整具有多个 UITableViewCells 时的高度

swift - Firebase swift - 无法将类型 'FIRUserInfoImpl' 的值转换为 'NSDictionary'

ios - Swift 什么是替换 TableViewCell 中内容的最佳方法

ios - bool 值 : EnableTransactions 的 Flutter 未知键