Short description: I get doesNotRecognizeSelector
error when call method on object that definitely has this method and it happens after calling respondsToSelector
.
It's a very strange situation and I didn't understand how it can be :). I saw this error in logs on some of user devices but not on all of them. I can't repeat this on my own device.
I'm trying to figure out how it can happen and added condition with respondsToSelector
but issue takes place again.
Some code bellow. Hope it helps
1) I've viewController
object in AppDelegate
.
@interface AppDelegate : NSObject <UIApplicationDelegate> {
}
@property (nonatomic, retain) AdRootViewController *viewController;
...
@end
@implementation AppDelegate
@synthesize viewController;
...
@end
2) In other class I'm trying to get this object and call one of its methods. But on [viewController showBanner]
call all fails with doesNotRecognizeSelector
error.
- (void) onEnterTransitionDidFinish {
[super onEnterTransitionDidFinish];
AdRootViewController *viewController = [(AppDelegate *)[[UIApplication sharedApplication] delegate] viewController];
if (viewController != nil && [viewController respondsToSelector:@selector(showBanner)]) {
[viewController showBanner];
}
}
3) AdRootViewController
has this method and it's declared in interface.
@interface AdRootViewController : UIViewController {
}
- (void)showBanner;
...
@end
@implementation AdRootViewController
...
- (void)showBanner
{
adBannerViewIsVisible = YES;
...
}
...
@end
The failed string of code is [viewController showBanner]
.
Error log looks like this:
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
...