Objective c 对象C两个委托具有相同的函数名:方法的重复声明';间质性IDreceivead:&x27;

Objective c 对象C两个委托具有相同的函数名:方法的重复声明';间质性IDreceivead:&x27;,objective-c,admob,inmobi,Objective C,Admob,Inmobi,GADInterstitialDelegate和iInterstitialDelegate具有相同的函数名:InterstitialDeleceiveAD //inmob - (void)interstitialDidReceiveAd:(IMInterstitial *)ad //callback:(id<IMInterstitialDelegate>)callback { [ad presentInterstitialAni

GADInterstitialDelegate和iInterstitialDelegate具有相同的函数名:
InterstitialDeleceiveAD

//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!");
}
//inmob
-(无效)间质受试者:(i间质*)受试者
//回调:(id)回调
{
[目前的机构动画:是];
NSLog(@“!!!inmob InterstitutialdReceivead ok”);
}
//当中间ad请求失败时发送
-(无效)间质:(i间质*)ad未接收到错误:(i错误*)错误
//回调:(id)回调
{
NSLog(@“!!!inmob didFailToReceiveAdWithError”);
//NSString*errorMessage=[NSString stringWithFormat:@“加载ad(%@)失败。错误代码:%d,消息://%@,[self.detailItem objectForKey:@“title”],[Error code],[Error localizedDescription];
//NSLog(@“%@”,错误消息);
}
//admob
-(空)间质IDreceivead:(GADInternitical*)间质ADMOB
{
NSLog(@“!!!admob InterstitutialdReceivead ok”);
}
-填隙的
//回调:(id)回调
DidFailtReceiveAvithError:(GADRequestError*)错误
{
NSLog(@“!!!!!!!admob间隙错误!”);
}

生成错误:方法“InterstitutionAlDidReceiveAD:”的重复声明。

Objective-C不允许使用相同名称但接受不同类型的多个方法。幸运的是,它也是弱类型的。因此,您应该能够逃脱:

- (void)interstitialDidReceiveAd:(id)interstitial
{
    if([interstitial isKindOfClass:[GADInterstitial class]])
        [self admobInterstitialDidReceiveAd:interstitial];
    else
        [self inmobiInterstitialDidReceiveAd:interstitial];
}

或者基于接收
id
并在其到达时检查其类型的任何此类更彻底的测试。

Objective-C不允许使用相同名称但接受不同类型的多个方法。幸运的是,它也是弱类型的。因此,您应该能够逃脱:

- (void)interstitialDidReceiveAd:(id)interstitial
{
    if([interstitial isKindOfClass:[GADInterstitial class]])
        [self admobInterstitialDidReceiveAd:interstitial];
    else
        [self inmobiInterstitialDidReceiveAd:interstitial];
}

或者任何基于接收
id
并在其到达时检查其类型的更彻底的测试。

您已经说明了问题,但您的问题具体是什么?您已经说明了问题,但您的问题具体是什么?