Using the latest SDK gives us access to all the latest features for the platform that we are developing for; however, there are times when we want to also target older platforms. Swift allows us to use the availability attribute to safely wrap code to run only when the correct version of the operating system is available. This availability was first introduced in Swift 2.
The availability blocks essentially let us, if we are running the specified version of the operating system or higher, run this code or otherwise run some other code. There are two ways in which we can use the availability attribute. The first way allows us to execute a specific block of code that can be used with an if or a guard statement. The second way allows us to mark a method or type as available...