Reputation: 18561
So we have a universal app and are getting a strange error where it seems like random iOS frameworks are trying to load our methods. So here are some of the crashes and the code its calling. Like I said it seems every random. It happens at random places in the app and at random times and on iPhone and iPad.
[__NSCFDictionary bannerViewDidLoadAd:]: unrecognized selector sent to instance 0x1f3f30
[__NSArrayM bannerViewDidLoadAd:]: unrecognized selector sent to instance 0x195ea0
[UILabel bannerView:didFailToReceiveAdWithError:]: unrecognized selector sent to instance 0x19f950
[ADSession bannerViewDidLoadAd:]: unrecognized selector sent to instance 0x106e20
[__NSArrayM bannerView:didFailToReceiveAdWithError:]: unrecognized selector sent to instance 0x521b670
And here is the code those refer to. For whatever reason...
- (void)bannerViewDidLoadAd:(ADBannerView *)banner {
if (!_adBannerViewIsVisible) {
_adBannerViewIsVisible = YES;
[self fixupAdView:[UIDevice currentDevice].orientation];
NSLog(@"iAD Loaded");
}
}
- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error {
NSLog(@"%@",error);
if (_adBannerViewIsVisible)
{
_adBannerViewIsVisible = NO;
[self fixupAdView:[UIDevice currentDevice].orientation];
NSLog(@"iAD Unloaded");
}
}
EDIT: I think we've narrowed it down to these. Can you guys see any glaring issues here?
- (void)createAdBannerView {
Class classAdBannerView = NSClassFromString(@"ADBannerView");
if (classAdBannerView != nil) {
[classAdBannerView release];
[self.adBannerView release];
self.adBannerView = [[classAdBannerView alloc] initWithFrame:CGRectZero];
[_adBannerView setRequiredContentSizeIdentifiers:[NSSet setWithObjects: ADBannerContentSizeIdentifierPortrait, ADBannerContentSizeIdentifierLandscape, nil]];
if (UIInterfaceOrientationIsLandscape([UIDevice currentDevice].orientation)) {
[_adBannerView setCurrentContentSizeIdentifier:ADBannerContentSizeIdentifierLandscape];
} else {
[_adBannerView setCurrentContentSizeIdentifier:ADBannerContentSizeIdentifierPortrait];
}
[_adBannerView setFrame:CGRectOffset([_adBannerView frame], 0, -[self getBannerHeight])];
[_adBannerView setDelegate:self];
[self.view addSubview:_adBannerView];
}
}
- (void)fixupAdView:(UIInterfaceOrientation)toInterfaceOrientation {
if (![[NSUserDefaults standardUserDefaults] boolForKey:@"isadFreeUpgradePurchased"]) {
if (_adBannerView != nil) {
if (UIInterfaceOrientationIsLandscape(toInterfaceOrientation)) {
[_adBannerView setCurrentContentSizeIdentifier:ADBannerContentSizeIdentifierLandscape];
} else {
[_adBannerView setCurrentContentSizeIdentifier:ADBannerContentSizeIdentifierPortrait];
}
[UIView beginAnimations:@"fixupViews" context:nil];
if (_adBannerViewIsVisible) {
CGRect adBannerViewFrame = [_adBannerView frame];
adBannerViewFrame.origin.x = 0;
adBannerViewFrame.origin.y = 0;
[_adBannerView setFrame:adBannerViewFrame];
CGRect contentViewFrame = _contentView.frame;
contentViewFrame.origin.y = [self getBannerHeight:toInterfaceOrientation];
contentViewFrame.size.height = self.view.frame.size.height - [self getBannerHeight:toInterfaceOrientation];
_contentView.frame = contentViewFrame;
} else {
CGRect adBannerViewFrame = [_adBannerView frame];
adBannerViewFrame.origin.x = 0;
adBannerViewFrame.origin.y = -[self getBannerHeight:toInterfaceOrientation];
[_adBannerView setFrame:adBannerViewFrame];
CGRect contentViewFrame = _contentView.frame;
contentViewFrame.origin.y = 0;
contentViewFrame.size.height = self.view.frame.size.height;
_contentView.frame = contentViewFrame;
}
[UIView commitAnimations];
}
}
}
Upvotes: 2
Views: 1476
Reputation: 45118
You get "unrecognized selector sent to instance" when you attempt to send a message to an object that does not have that method.
For example NSDictionary does not have bannerViewDidLoadAd method but ADBannerView presumably does. So you are just passing the wrong object. Just put a break point in the line of the error and see where that object comes from.
(just a guess: maybe you are iterating some dictionary/array?, because dictionaries and arrays can contain anything)
Upvotes: 0
Reputation: 17958
it seems like random iOS frameworks are trying to load our methods
You've got that backwards, you're sending those messages to random framework objects. This is almost always a sign that you have a pointer to a deallocated object and your attempts to send messages to that object are instead being sent to some new object at the same memory address.
You need to look for users of the class containing these methods and determine where you are attempting to access a released instance.
Upvotes: 4