我遇到了无法识别的选择器:
-[NSNull _isCString]: unrecognized selector sent to instance
给定的日志崩溃了我的应用程序。导致此错误的可能原因是什么?谁能提出一些想法?任何回复都将非常感谢。非常感谢你!
实际上,我只是想从表视图控制器编辑一行。我注意到当我在表视图控制器的导航栏上单击编辑时,行0,2和4会收到错误,但行1和3不会。
2014-08-13 11:39:27.531 boysenios[5253:60b] -[NSNull _isCString]: unrecognized selector sent to instance 0x2068068
2014-08-13 11:39:27.535 boysenios[5253:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSNull _isCString]: unrecognized selector sent to instance 0x2068068'
*** First throw call stack:
(
0 CoreFoundation 0x01f1c1e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x01c9b8e5 objc_exception_throw + 44
2 CoreFoundation 0x01fb9243 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x01f0c50b ___forwarding___ + 1019
4 CoreFoundation 0x01f0c0ee _CF_forwarding_prep_0 + 14
5 Foundation 0x018cc986 -[NSBigMutableString replaceCharactersInRange:withString:] + 317
6 Foundation 0x018cc815 -[NSConcreteMutableAttributedString replaceCharactersInRange:withAttributedString:] + 384
7 UIFoundation 0x03e86774 __71-[NSConcreteTextStorage replaceCharactersInRange:withAttributedString:]_block_invoke + 68
8 UIFoundation 0x03e866af -[NSConcreteTextStorage replaceCharactersInRange:withAttributedString:] + 121
9 Foundation 0x018f6f76 -[NSMutableAttributedString setAttributedString:] + 90
10 UIKit 0x01065c6c __32-[UITextView setAttributedText:]_block_invoke + 43
11 UIFoundation 0x03e84211 -[NSTextStorage coordinateEditing:] + 48
12 UIKit 0x010658cb -[UITextView setAttributedText:] + 254
13 UIKit 0x01069eb5 -[UITextView setText:] + 149
14 boysenios 0x000233c6 -[ProjectFormTableViewController resetView] + 3873
15 boysenios 0x00022494 -[ProjectFormTableViewController setViewToEdit:] + 61
16 libobjc.A.dylib 0x01cad880 -[NSObject performSelector:withObject:withObject:] + 77
17 UIKit 0x0095d3b9 -[UIApplication sendAction:to:from:forEvent:] + 108
18 UIKit 0x00c4a8df -[UIBarButtonItem(UIInternal) _sendAction:withEvent:] + 139
19 libobjc.A.dylib 0x01cad880 -[NSObject performSelector:withObject:withObject:] + 77
20 UIKit 0x0095d3b9 -[UIApplication sendAction:to:from:forEvent:] + 108
21 UIKit 0x0095d345 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
22 UIKit 0x00a5ebd1 -[UIControl sendAction:to:forEvent:] + 66
23 UIKit 0x00a5efc6 -[UIControl _sendActionsForEvents:withEvent:] + 577
24 UIKit 0x00a5e243 -[UIControl touchesEnded:withEvent:] + 641
25 UIKit 0x0099cddd -[UIWindow _sendTouchesForEvent:] + 852
26 UIKit 0x0099d9d1 -[UIWindow sendEvent:] + 1117
27 UIKit 0x0096f5f2 -[UIApplication sendEvent:] + 242
28 UIKit 0x00959353 _UIApplicationHandleEventQueue + 11455
29 CoreFoundation 0x01ea577f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
30 CoreFoundation 0x01ea510b __CFRunLoopDoSources0 + 235
31 CoreFoundation 0x01ec21ae __CFRunLoopRun + 910
32 CoreFoundation 0x01ec19d3 CFRunLoopRunSpecific + 467
33 CoreFoundation 0x01ec17eb CFRunLoopRunInMode + 123
34 GraphicsServices 0x033345ee GSEventRunModal + 192
35 GraphicsServices 0x0333442b GSEventRun + 104
36 UIKit 0x0095bf9b UIApplicationMain + 1225
37 boysenios 0x00027f83 main + 94
38 libdyld.dylib 0x02fcd701 start + 1
39 ??? 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
答案 0 :(得分:2)
NSNull
是一个类没有实现_isCString
的类,因此无法识别的选择器错误。 Objective-C通常使用nil
来表示0或空指针值。但是,NSDictionary
和NSArray
等标准容器无法保留nil值,因此您偶尔会看到使用[NSNull null]
。
您的代码中的基本惯例决定了您是否检查myVal == [NSNull null]
或myVal == nil
。
根据您发布的跟踪,您似乎需要在某处进行myVal == [NSNull null]
检查。