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?

有帮助吗?

解决方案

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

if ([self respondsToSelector:@selector(setCanDisplayBannerAds:)]) {
    self.canDisplayBannerAds = YES;
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top