Gan*_*ank 1 objective-c admob inmobi
GADInterstitialDelegate和IMInterstitialDelegate具有相同的函数名称: interstitialDidReceiveAd
//inmob
- (void)interstitialDidReceiveAd:(IMInterstitial *)ad
//callback:(id<IMInterstitialDelegate>)callback
{
[ad presentInterstitialAnimated:YES];
NSLog(@"!!! inmob interstitialDidReceiveAd ok ");
}
// Sent when an interstitial ad request failed
- (void)interstitial:(IMInterstitial *)ad didFailToReceiveAdWithError:(IMError *)error
//callback:(id<IMInterstitialDelegate>)callback
{
NSLog(@"!!! inmob didFailToReceiveAdWithError ");
// NSString *errorMessage = [NSString stringWithFormat:@"Loading ad (%@) failed. Error code: %d, message: //%@", [self.detailItem objectForKey:@"title"], [error code], [error localizedDescription]];
//NSLog(@"%@", errorMessage);
}
//admob
- (void)interstitialDidReceiveAd:(GADInterstitial *)interstitialAdmob
{
NSLog(@"!!! admob interstitialDidReceiveAd ok");
}
- (void)interstitial:(GADInterstitial *)interstitial
//callback:(id<GADInterstitialDelegate>)callback
didFailToReceiveAdWithError:(GADRequestError *)error
{
NSLog(@"!!!!!!! admob interstitial error!");
}
Run Code Online (Sandbox Code Playgroud)
构建错误:方法'interstitialDidReceiveAd:'的重复声明
Objective-C不允许多个具有相同名称但接受不同类型的方法.幸运的是它也是弱类型的.所以你应该能够逃脱:
- (void)interstitialDidReceiveAd:(id)interstitial
{
if([interstitial isKindOfClass:[GADInterstitial class]])
[self admobInterstitialDidReceiveAd:interstitial];
else
[self inmobiInterstitialDidReceiveAd:interstitial];
}
Run Code Online (Sandbox Code Playgroud)
或任何此类更彻底的测试,基于接收id并在其到达时检查其类型.
| 归档时间: |
|
| 查看次数: |
432 次 |
| 最近记录: |