1

I am trying to create a singleton class, subclass of GADRewardBasedVideoAdDelegate. Something like this:

import Foundation
import GoogleMobileAds
class MyAdsManager : GADRewardBasedVideoAdDelegate {
    private let id : String = "MY_ADMOB_ID"
    private var selector : (()->Void)?
    static let instance: MyAdsManager = {
        return MyAdsManager()
    }()

    class func getInstance() -> MyAdsManager {
        return instance
    }

    private init() {
        loadVideo()
    }

    //more methods
}

The error message is:

Type 'MyAdsManager' does not conform to protocol 'NSObjectProtocol'

I am not sure if I am doing this correctly, but implementing NSObjectProtocol is not something I am looking for...

Thank you in advance people.

Shehata Gamal
  • 98,760
  • 8
  • 65
  • 87
Amg91
  • 165
  • 8
  • 25
  • That was fast and yes, it works. Thank you. Why is that `NSObject`? Sorry, I'm still learning... – Amg91 Nov 30 '18 at 00:27

1 Answers1

1

Replace

class MyAdsManager : GADRewardBasedVideoAdDelegate

with

class MyAdsManager : NSObject, GADRewardBasedVideoAdDelegate 

Reason

GADRewardBasedVideoAdDelegate inherits from NSObjectProtocol so you have to implement all methods listed in NSObjectProtocol and since these methods are implemented inside NSObject subclasses so it does the job for you

Shehata Gamal
  • 98,760
  • 8
  • 65
  • 87