DoesNotRecognizeSelector error after a SoSelector check response

Short Description: I get an error doesNotRecognizeSelectorwhen calling a method on an object that definitely has this method, and this happens after the call respondsToSelector.

This is a very strange situation, and I did not understand how this could be :). I saw this error in the logs on some user devices, but not on all of them. I cannot repeat this on my own device.

I am trying to figure out how this can happen, and condition c has been added respondsToSelector, but the problem is happening again.

Below is the code. Hope this helps.

1) I am viewControllerin AppDelegate.

@interface AppDelegate : NSObject <UIApplicationDelegate> {
}
@property (nonatomic, retain) AdRootViewController *viewController;
...
@end

@implementation AppDelegate
@synthesize viewController;
...
@end

2) In another class, I try to get this object and call one of its methods. But to [viewController showBanner]call all failed with an error doesNotRecognizeSelector.

- (void) onEnterTransitionDidFinish {
    [super onEnterTransitionDidFinish];

    AdRootViewController *viewController = [(AppDelegate *)[[UIApplication sharedApplication] delegate] viewController];
    if (viewController != nil && [viewController respondsToSelector:@selector(showBanner)]) {
        [viewController showBanner];
    }
}

3) AdRootViewController .

@interface AdRootViewController : UIViewController {
}
- (void)showBanner;
...
@end

@implementation AdRootViewController
...
- (void)showBanner
{
    adBannerViewIsVisible = YES;
    ...
}
...
@end

[viewController showBanner].

:

1 CoreFoundation __exceptionPreprocess + 1245624
2 libobjc.A.dylib objc_exception_throw + 34136
3 CoreFoundation -[NSObject(NSObject) doesNotRecognizeSelector:] + 1274468
4 CoreFoundation ___forwarding___ + 1262188
5 CoreFoundation _CF_forwarding_prep_0 + 186376
6 <project_id> 4296487336 + 487848
...

P.S. , : enter image description here

+4
2

, , .

jailbroken , . . , .

. ​​, , - , , (, . http://www.tenorshare.com/guide/how-to-block-ads-on-iphone-ipad-ipod.html)

, AdRootViewController. , , showBanner.

, jailbroken- ( crashlytics , ).

, , . .

+1

. , , respondsToSelector:@selector(showBanner) , , , , , viewController nil

-, , , , , .

appDelegate - NSObject, UIResponder, NSObject UIResponder

@interface AppDelegate : UIResponder <UIApplicationDelegate> {
}

, ,

0

Source: https://habr.com/ru/post/1666800/


All Articles