0

I'm getting a rare crash in my iOS app when resuming from the background. I see -[NSObject doesNotRecognizeSelector:] in the exception backtrace but there is little more information. Any idea where I might start looking?

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
kenem
  • 5
  • 1
  • 3

1 Answers1

0

It seems that you are calling a method that dosen't belong to an object. It means your object on which you are calling a method is NSObject type and a method that you are calling is not availabel on NSObject. This used to happen when we are doing type casting.

For eg.

 NSObject *obj = [NSObject new];
[(UIView *)obj setBackgroundColor:[UIColor whiteColor]]; // it will crash for unrecognize selector call

So the solution is to check the object using isKindOfClass: and then call a method thats belongs to it.

Mahendra
  • 8,448
  • 3
  • 33
  • 56
  • Thank you, that's very helpful. Do you have any idea where I could be doing that? It's not very clear from the backtrace, since all it tells me is that I'm calling `-[UIApplication UIApplicationMain]` from `main()`. – kenem Sep 30 '17 at 07:51
  • Put exception break point and then run app, You will get line of code where app is crashing. At that place you can add use `[obj isKindOfClass:[YourClass class]]`. – Mahendra Sep 30 '17 at 08:07
  • I don't know how to reproduce the issue, and it's very rare, but I'll keep trying. Thank you for your help. – kenem Oct 02 '17 at 07:02