Is it safe to conditionally encode iOS 6 and 7 by calling a + class?

For example, in iOS 7 there is a new class that does not exist in iOS 6. I want to use this new class. My application should remain compatible with iOS 6. Therefore, I read in some places that you can now do this:

if ([NSURLSessionConfiguration class]) { // only in iOS 7 } else { // do it iOS6 way } 

Is it safe to do this in any version of iOS 6 or should we use NSClassFromString ?

+8
ios iphone xcode ios7
source share
1 answer

YES, it's safe.

This is the correct and recommended way to check if certain classes are available.

+9
source share

All Articles