[英][NSNull length]: unrecognized selector sent to instance on keyboard keystroke?
我在静态表视图上添加了一些textField和textView 。 该代码很好,并且可以在xcode 6.4 / ios 8上运行。 *但是它抛出了异常,我无法跟踪。 现在我正在xcode 7.2(swift2.2)上调试代码
我也尝试放置象征性和特殊的断点,但没有运气:(
以下是崩溃的堆栈跟踪信息,在此先感谢您的宝贵帮助。
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或类似的东西”时,我们知道这是错误的。 第二个最重要的规则: 信任证据 。
证据是将作为NSString方法的消息“ length:”发送到[NSNull null]。 您将在其中存储[NSNull null]的位置存储字符串。 调试的第三条规则: 您做错了什么。 没有神秘的gremlins试图让您难过,这是您的代码错误。 因此,找出您要存储[NSNull null]的位置。 来自JSON解析器的任何内容始终都是不错的选择。
可能的解决方案 :
造成我的问题的原因是,我无意中单击了属性检查器中的“键命令”控件。
在这里查看我的回复: https : //stackoverflow.com/a/36187611/5006807
希望对您有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.