Check iOS Version Number in Swift & Objective-C

Andrew Bancroft:

When accommodating iOS 7 users, you’ll inevitably run into instances where you need to check which iOS version the device is running, so that you can implement a fall-back plan for older versions of iOS.

In Objective-C, I’ve seen this accomplished by using pre-processor directives, or with introspection. Swift, however, has no pre-processor directives in v1.0…

As Andrew demonstrates, you can use NSFoundationVersionNumber for both Objective-C and Swift.