문제

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