iPhone applcation crash in admob_iphone_sdk_20100818
My program has crashed:
#0 0x3138cec0 in objc_msgSend
#1 0x0002bb开发者_C百科6e 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".
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!
精彩评论