Question

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?

Was it helpful?

Solution

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

if ([self respondsToSelector:@selector(setCanDisplayBannerAds:)]) {
    self.canDisplayBannerAds = YES;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top