0

I'm crashing with unrecognized selector sent to instance xxxx

but in LLDB I can confirm that the object should be responding:

(lldb) po [0x7fce2b95d480 class]
XXXViewController
(lldb) e (BOOL)[0x7fce2b95d480 respondsToSelector:@selector(viewDidAppear:)]
(BOOL) $2 = YES
(lldb) e (void)[0x7fce2b95d480 viewDidAppear:YES]
error: Execution was interrupted, reason: breakpoint 1.1.
The process has been returned to the state before expression evaluation.
2015-12-13 18:19:09.316 [13959:7671911] -[XXXViewController viewDidAppear:]: unrecognized selector sent to instance 0x7fce2b95d480

And my callstack symbols are:

(lldb) po [NSThread callStackSymbols]
<_NSCallStackArray 0x7fce2f2dea70>(
0   ???                                 0x00000001136d9b25 0x0 + 4620917541,
1   xxxxxx                          0x000000010095c5b0 main + 0,
2   CoreFoundation                      0x0000000103b67d07 ___forwarding___ + 487,
3   CoreFoundation                      0x0000000103b67a98 _CF_forwarding_prep_0 + 120,
4   UIKit                               0x0000000101607675 -[UIViewController _setViewAppearState:isAnimating:] + 830,
5   UIKit                               0x000000010164072e -[UINavigationController viewDidAppear:] + 207,
6   UIKit                               0x000000011158ff6e -[UINavigationControllerAccessibility viewDidAppear:] + 46,
7   UIKit                               0x0000000101607675 -[UIViewController _setViewAppearState:isAnimating:] + 830,
8   UIKit                               0x0000000101607ff8 -[UIViewController _endAppearanceTransition:] + 262,
9   UIKit                               0x00000001015d289e -[UIPresentationController transitionDidFinish:] + 827,
10  UIKit                               0x00000001017a724f -[_UICurrentContextPresentationController transitionDidFinish:] + 42,
11  UIKit                               0x00000001015d5fd5 __56-[UIPresentationController runTransitionForCurrentState]_block_invoke_2 + 183,
12  UIKit                               0x0000000101e68b24 -[_UIViewControllerTransitionContext completeTransition:] + 101,
13  UIKit                               0x00000001015cf6b6 -[UITransitionView notifyDidCompleteTransition:] + 252,
14  UIKit                               0x00000001015cf3c6 -[UITransitionView _didCompleteTransition:] + 1598,
15  UIKit                               0x0000000111583d5c -[UITransitionViewAccessibility _didCompleteTransition:] + 42,
16  UIKit                               0x00000001015d1c08 -[UITransitionView _transitionDidStop:finished:] + 104,
17  UIKit                               0x00000001014f79df -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 241,
18  UIKit                               0x00000001014f7d8e -[UIViewAnimationState animationDidStop:finished:] + 80,
19  UIKit                               0x00000001115abaa3 -[UIViewAnimationStateAccessibility animationDidStop:finished:] + 121,
20  QuartzCore                          0x00000001040acfa0 _ZN2CA5Layer23run_animation_callbacksEPv + 308,
21  libdispatch.dylib                   0x000000010489f49b _dispatch_client_callout + 8,
22  libdispatch.dylib                   0x00000001048872af _dispatch_main_queue_callback_4CF + 1738,
23  CoreFoundation                      0x0000000103b722e9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9,
24  CoreFoundation                      0x0000000103b338a9 __CFRunLoopRun + 2073,
25  CoreFoundation                      0x0000000103b32e08 CFRunLoopRunSpecific + 488,
26  GraphicsServices                    0x00000001068f5ad2 GSEventRunModal + 161,
27  UIKit                               0x000000010146f30d UIApplicationMain + 171,
28  xxxx                          0x000000010095c61f main + 111,
29  libdyld.dylib                       0x00000001048d392d start + 1

EDIT FOR COMPLETENESS

2015-12-13 18:28:55.928 XXXX[13959:7671911] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[XXXViewController viewDidAppear:]: unrecognized selector sent to instance 0x7fce2b95d480'
*** First throw call stack:
(
    0   CoreFoundation                      0x0000000103c11f45 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x000000010368bdeb objc_exception_throw + 48
    2   CoreFoundation                      0x0000000103c1a56d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
    3   CoreFoundation                      0x0000000103b67d07 ___forwarding___ + 487
    4   CoreFoundation                      0x0000000103b67a98 _CF_forwarding_prep_0 + 120
    5   UIKit                               0x0000000101607675 -[UIViewController _setViewAppearState:isAnimating:] + 830
    6   UIKit                               0x000000010164072e -[UINavigationController viewDidAppear:] + 207
    7   UIKit                               0x000000011158ff6e -[UINavigationControllerAccessibility viewDidAppear:] + 46
    8   UIKit                               0x0000000101607675 -[UIViewController _setViewAppearState:isAnimating:] + 830
    9   UIKit                               0x0000000101607ff8 -[UIViewController _endAppearanceTransition:] + 262
    10  UIKit                               0x00000001015d289e -[UIPresentationController transitionDidFinish:] + 827
    11  UIKit                               0x00000001017a724f -[_UICurrentContextPresentationController transitionDidFinish:] + 42
    12  UIKit                               0x00000001015d5fd5 __56-[UIPresentationController runTransitionForCurrentState]_block_invoke_2 + 183
    13  UIKit                               0x0000000101e68b24 -[_UIViewControllerTransitionContext completeTransition:] + 101
    14  UIKit                               0x00000001015cf6b6 -[UITransitionView notifyDidCompleteTransition:] + 252
    15  UIKit                               0x00000001015cf3c6 -[UITransitionView _didCompleteTransition:] + 1598
    16  UIKit                               0x0000000111583d5c -[UITransitionViewAccessibility _didCompleteTransition:] + 42
    17  UIKit                               0x00000001015d1c08 -[UITransitionView _transitionDidStop:finished:] + 104
    18  UIKit                               0x00000001014f79df -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 241
    19  UIKit                               0x00000001014f7d8e -[UIViewAnimationState animationDidStop:finished:] + 80
    20  UIKit                               0x00000001115abaa3 -[UIViewAnimationStateAccessibility animationDidStop:finished:] + 121
    21  QuartzCore                          0x00000001040acfa0 _ZN2CA5Layer23run_animation_callbacksEPv + 308
    22  libdispatch.dylib                   0x000000010489f49b _dispatch_client_callout + 8
    23  libdispatch.dylib                   0x00000001048872af _dispatch_main_queue_callback_4CF + 1738
    24  CoreFoundation                      0x0000000103b722e9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
    25  CoreFoundation                      0x0000000103b338a9 __CFRunLoopRun + 2073
    26  CoreFoundation                      0x0000000103b32e08 CFRunLoopRunSpecific + 488
    27  GraphicsServices                    0x00000001068f5ad2 GSEventRunModal + 161
    28  UIKit                               0x000000010146f30d UIApplicationMain + 171
    29  XXX                          0x000000010095c61f main + 111
    30  libdyld.dylib                       0x00000001048d392d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

EDIT 2: A more complete example: (Apologize for lack of formatting, SO edit banner not working)

I am adding aspects on UIViewController using the library by @steipete

https://github.com/steipete/Aspects

```

#import "Aspects.h"

Class baseClass = [self baseClass:class selector:selector];
__weak __typeof__(self) weakSelf = self;
    id aspect = [baseClass aspect_hookSelector:selector withOptions:AspectPositionAfter usingBlock:^(id <AspectInfo> info) {
        __typeof__(weakSelf) strongSelf = weakSelf;
        id instance = info.instance;
        [strongSelf didCall:[instance class] selector:selector info:info signiture:signiture];
    } error:err];
```
rmaddy
  • 314,917
  • 42
  • 532
  • 579
Avba
  • 14,822
  • 20
  • 92
  • 192
  • You forgot to add the complete error message from the crash. Don't show just part of the "unrecognized selector" error. – rmaddy Dec 13 '15 at 16:27
  • There is nothing to see. The call stack is all I have – Avba Dec 13 '15 at 16:28
  • Really? You post a question about a crash and you don't think the complete error message is worth posting? – rmaddy Dec 13 '15 at 16:29
  • 1) have you tried to clean the project and rebuild it? – Michael Dec 13 '15 at 16:54
  • 2) have you really named your view controller XXXViewController? Can you make an [mcve](http://stackoverflow.com/help/mcve)? – Michael Dec 13 '15 at 16:56
  • 1
    3) also, you have obviously done something fancy with the objc-runtime. if so, you should post the code. why else would you tag your question with the "swizzling" tag? – Michael Dec 13 '15 at 16:59
  • 4) I think you have also overridden -respondsToSelector:, so you have probably tried to implement some kind of proxy. – Michael Dec 13 '15 at 17:03
  • about Edit-2: "more complete" is not "complete enough". i'm an expert in objc-runtime-internals, i could probably fix this issue in a minute if i would see the actual source code. unless you provide an mcve, you will not get an answer. – Michael Dec 13 '15 at 18:34
  • I'm trying to produce a simple example, but of course its not crashing... I'll keep trying – Avba Dec 13 '15 at 18:47

0 Answers0