views:

85

answers:

3

My program has crashed:

#0      0x3138cec0 in objc_msgSend
#1      0x0002bb6e in -[AdMobDelegateWrapper didYouNilOutYourDelegate:]
#2      0x0002c392 in -[AdMobDelegateWrapper publisherId]
#3      0x0001ab7e in -[AdMobAd buildParamsWithLastClickInfo:]
#4      0x0001b044 in -[AdMobAd requestAdFromServer]
#5      0x0001963c in -[AdMobAd browserIconsDidFinishLoading]
#6      0x0001a23e in -[AdMobAd downloadDidSucceed:]
#7      0x323fba14 in -[NSObject performSelector:withObject:]
#8      0x0002122e in -[AdMobURLDownload performRequest:]
#9      0x33731acc in -[NSThread main]
#10     0x336dfd14 in __NSThread__main__
#11     0x33ad8788 in _pthread_body

why?

I use 4.0 SDK and device's system version is iOS 3.1.3.

My codes is very simple that from examples which in "admob_iphone_sdk_20100818".

A: 

I got this too but i dont know why..

Raphael
A: 

Im having the very same crash.

I think its releated with not releasing the delegate when the view is unloaded. I have this code in place:

- (void)viewDidLoad {
    [super viewDidLoad];
    adMobAd = [AdMobView requestAdWithDelegate:self]; // start a new ad request
    [adMobAd retain];
}
- (void)viewDidUnload {
    if (adMobAd != nil){
        adMobAd.delegate = nil;
    }
}
- (void)dealloc {
    [adMobAd release];

    [super dealloc];
}

But Im still getting the crash.

Odd thing is I cant replicate the crash in debug mode (either simulator or device).

Any pointers on how to solve it?

Thanks in advance.

Gonso

gonso
A: 

Ok, I found the solution. I was almost there but not quite. The problem IS setting the delegate to nil, but the place was wrong.

This is how I solved it:

- (void)viewDidLoad {
    [super viewDidLoad];
    adMobAd = [AdMobView requestAdWithDelegate:self]; // start a new ad request
    [adMobAd retain];
}
- (void)viewDidUnload {
    //Nothing to do here
}
- (void)dealloc {
    //THIS IS THE IMPORTANT STUFF
    if (adMobAd != nil){
       adMobAd.delegate = nil;
    }
    [adMobAd release];

    [super dealloc];
}

Moving the "liberation" of the delegate to the dealloc block has fixed the problem for me.

Hope it helps!

gonso