Why AnyObject or Any conversion is failing to GADUnifiedNativeAd in swift5?

66 Views Asked by At

I am using Google Ad and I am converting GADUnifiedNativeAd to AnyObject and converting back original GADUnifiedNativeAd is failing in Swift 5 . What can be the reason? Before this code working fine in Swift 4.2 and below:

GADUnifiedNativeAd

on delegate response of fetching Ad

func adLoader(_ adLoader: GADAdLoader, didReceive nativeAd: GADUnifiedNativeAd) {
    let anyObjectTo: AnyObject = nativeAd
    if let nativeAd = anyObjectTo as? GADUnifiedNativeAd {
        print("success")
    } else {
        print("failing")
    }
}
0

There are 0 best solutions below