سؤال

I'm getting a strange crash with the iAd error callback. Here is my crash log:

Exception Type: EXC_BAD_ACCESS Code: KERN_INVALID_ADDRESS at 0x2281
0com.apple.main-thread Crashed
0    libobjc.A.dylib     objc_retain + 17
1    YouDoodle AdView.m line 265 -[AdContainerView requestGAD]
2    iAd     -[ADBannerView _forwardErrorToDelegate:] + 254
3    iAd     -[ADBannerView serverBannerViewDidFailToReceiveAdWithError:] + 178
4    iAd     -[ADAdSpace setServiceAdSpace:] + 472
5    CoreFoundation  __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
6    CoreFoundation  _CFXNotificationPost + 1718
7    Foundation  -[NSNotificationCenter postNotificationName:object:userInfo:] + 76
8    Foundation  -[NSNotificationCenter postNotificationName:object:] + 30
9    iAd     -[ADAdSheetProxy _adSheetConnectionLost] + 292
10 ...   libdispatch.dylib   _dispatch_call_block_and_release + 10
11   libdispatch.dylib   _dispatch_client_callout + 22
12   libdispatch.dylib   _dispatch_main_queue_callback_4CF$VARIANT$up + 274
13   CoreFoundation  __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 8
14   CoreFoundation  __CFRunLoopRun + 1300
15   CoreFoundation  CFRunLoopRunSpecific + 522
16   CoreFoundation  CFRunLoopRunInMode + 106
17   GraphicsServices    GSEventRunModal + 138
18   UIKit   UIApplicationMain + 1136
19   YouDoodle  
AppDelegate.m line 129
main

http://crashes.to/s/c654d14dcfa

delegate callback for iAd:

- (void) bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
    DLog(@"IAD Failed to load with error %@", error);

    self.adBannerContainer.hidden = YES;

    if (InternetAvailableWithAlert(NO))
    {
        if (self.gadAvailable)
        {
            self.gadBannerContainer.hidden = NO;
        }
        else
        {
            [self requestGAD];
        }
    }
}

- (void) requestGAD
{
    GADRequest* request = [[GADRequest alloc] init];

#if TARGET_IPHONE_SIMULATOR

    request.testDevices = @[GAD_SIMULATOR_ID];

#endif

    self.gadBanner.rootViewController = (self.gadBanner.rootViewController ?: self.viewController);
    [self.gadBanner loadRequest:request];
}

The iAd view delegate is a singleton which is never released. Even if it was released, the iAd class delegate property is a weak property so it should auto-nil.

@property (nonatomic, weak) id<ADBannerViewDelegate> delegate;

Ideas?

هل كانت مفيدة؟

المحلول

This was due to setting the Admob SDK root view controller back to itself, when the view controller has been deallocated, this crashes. Admob SDK uses an assign reference instead of weak which is why it crashed.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top