Pergunta

With iOS 7 Apple introduced a new iAd function:

self.canDisplayBannerAds = YES;

In iOS 7 this works great. But if i run my App on an iOS 6 device, the App crashes.

In this way it works:

    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7)
   {
    self.canDisplayBannerAds = YES;
   }

My question: is this the normal way, or is there a better solution?

Foi útil?

Solução

The better solution is to check if the method is available:

if ([self respondsToSelector:@selector(setCanDisplayBannerAds:)]) {
    self.canDisplayBannerAds = YES;
}
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top