我从后台恢复时,在我的iOS应用中遇到罕见的崩溃。我在异常回溯中看到-[NSObject doesNotRecognizeSelector:]
,但没有更多信息。我知道在哪里开始寻找吗?
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Triggered by Thread: 0
Application Specific Information:
abort() called
Filtered syslog:
None found
Last Exception Backtrace:
0 CoreFoundation 0x18f7291b8 __exceptionPreprocess + 124
1 libobjc.A.dylib 0x18e16055c objc_exception_throw + 55
2 CoreFoundation 0x18f730268 -[NSObject+ 1274472 (NSObject) doesNotRecognizeSelector:] + 139
3 CoreFoundation 0x18f72d270 ___forwarding___ + 915
4 CoreFoundation 0x18f62680c _CF_forwarding_prep_0 + 91
5 CoreFoundation 0x18f6d6b5c __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 23
6 CoreFoundation 0x18f6d6434 __CFRunLoopDoSources0 + 411
7 CoreFoundation 0x18f6d40a4 __CFRunLoopRun + 803
8 CoreFoundation 0x18f6022b8 CFRunLoopRunSpecific + 443
9 GraphicsServices 0x1910b6198 GSEventRunModal + 179
10 UIKit 0x1956427fc -[UIApplication _run] + 683
11 UIKit 0x19563d534 UIApplicationMain + 207
12 MyApp 0x100040d04 0x10003c000 + 19716
13 libdyld.dylib 0x18e5e55b8 start + 3
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x000000018e6f7014 __pthread_kill + 8
1 libsystem_pthread.dylib 0x000000018e7bf450 pthread_kill + 112
2 libsystem_c.dylib 0x000000018e66b400 abort + 140
3 libc++abi.dylib 0x000000018e1352d4 __cxa_bad_cast + 0
4 libc++abi.dylib 0x000000018e152cc0 default_unexpected_handler+ 126144 () + 0
5 libobjc.A.dylib 0x000000018e160844 _objc_terminate+ 34884 () + 124
6 libc++abi.dylib 0x000000018e14f66c std::__terminate(void (*)+ 112236 ()) + 16
7 libc++abi.dylib 0x000000018e14f234 __cxa_rethrow + 144
8 libobjc.A.dylib 0x000000018e16071c objc_exception_rethrow + 44
9 CoreFoundation 0x000000018f60232c CFRunLoopRunSpecific + 560
10 GraphicsServices 0x00000001910b6198 GSEventRunModal + 180
11 UIKit 0x00000001956427fc -[UIApplication _run] + 684
12 UIKit 0x000000019563d534 UIApplicationMain + 208
13 MyApp 0x0000000100040d04 0x10003c000 + 19716
14 libdyld.dylib 0x000000018e5e55b8 start + 4
答案 0 :(得分:0)
看来你正在调用一个不属于某个对象的方法。这意味着您调用方法的对象是NSObject
类型,并且您调用的方法在NSObject
上不可用。过去常常在我们进行类型转换时发生。
例如。
NSObject *obj = [NSObject new];
[(UIView *)obj setBackgroundColor:[UIColor whiteColor]]; // it will crash for unrecognize selector call
所以解决方法是使用isKindOfClass:
检查对象,然后调用属于它的方法。