Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/100.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 我将如何在swift中实施该协议?_Ios_Swift_Admob - Fatal编程技术网

Ios 我将如何在swift中实施该协议?

Ios 我将如何在swift中实施该协议?,ios,swift,admob,Ios,Swift,Admob,如果我有一个名为MyIntersitial的类,我将如何在其中实现这个objective c协议。任何提示都将不胜感激。我刚刚得到“不符合协议”错误 Swift: import Foundation import GoogleMobileAds class myInterstitial: GADCustomEventInterstitial{ //... implements here } #import <UIKit/UIKit.h> #import "GADCustomEven

如果我有一个名为MyIntersitial的类,我将如何在其中实现这个objective c协议。任何提示都将不胜感激。我刚刚得到“不符合协议”错误

Swift:

import Foundation
import GoogleMobileAds
class myInterstitial: GADCustomEventInterstitial{
//... implements here
}
#import <UIKit/UIKit.h>
#import "GADCustomEventInterstitialDelegate.h"
#import "GADCustomEventRequest.h"


    @protocol GADCustomEventInterstitial<NSObject>

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


    - (void)requestInterstitialAdWithParameter:(NSString *)serverParameter
                                         label:(NSString *)serverLabel
                                       request:(GADCustomEventRequest *)request;

    - (void)presentFromRootViewController:(UIViewController *)rootViewController;

    @end
Objective-c协议:

import Foundation
import GoogleMobileAds
class myInterstitial: GADCustomEventInterstitial{
//... implements here
}
#import <UIKit/UIKit.h>
#import "GADCustomEventInterstitialDelegate.h"
#import "GADCustomEventRequest.h"


    @protocol GADCustomEventInterstitial<NSObject>

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


    - (void)requestInterstitialAdWithParameter:(NSString *)serverParameter
                                         label:(NSString *)serverLabel
                                       request:(GADCustomEventRequest *)request;

    - (void)presentFromRootViewController:(UIViewController *)rootViewController;

    @end
#导入
#导入“gadcustomeventraldelegate.h”
#导入“GADCustomEventRequest.h”
@协议间性
@属性(非原子,弱)id委托;
-(void)RequestInterstitutionAladWithParameter:(NSString*)服务器参数
标签:(NSString*)服务器标签
请求:(GADCustomEventRequest*)请求;
-(void)presentFromRootViewController:(UIViewController*)rootViewController;
@结束

您必须在协议之前列出一个超类(或NSObject)。我还建议您将类名大写

import Foundation

class MyInterstitial: NSObject, GADCustomEventInterstitial {

    var delegate: GADCustomEventInterstitialDelegate?

    func requestInterstitialAdWithParameter(serverParameter: String!, label serverLabel: String!, request: NSObject!) {
        // implementation here
    }

    func presentFromRootViewController(rootViewController: UIViewController!) {
        // implementation here
    }
}

您是否将GADCustomEventInterstitual添加到“xxx桥接头.h”中?按cmd并单击GADCustomEventInterstitial时,它的确切位置在哪里?