Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it safe to conditionally code for iOS 6 and 7 by calling +class?

For example there is a new class in iOS 7 that does not exist in iOS 6. I want to use this new class. My app must stay compatible with iOS 6. So I read in some places that you can now do this:

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

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

like image 585
openfrog Avatar asked Sep 21 '13 21:09

openfrog


1 Answers

YES, this is safe.

This is the correct and recommended way of checking to see if certain classes are available to be used.

like image 190
Dave DeLong Avatar answered Oct 31 '22 13:10

Dave DeLong