Swift basics - Availability Attribute

Availability Attribute:
Helps to ensure that a minimum OS is used:
if #available(iOS 9.0, OSX 10.10, watchOS 2, *){//requirements met}else{}

We can ensure that certain code is available where a certain OS is available:
@available(iOS 9.0, *) //means iOS 9 or later
func thisFunctionIsOnlyAvailableAfterIOS9(){}

@available(iOS 9.0, *) //means iOS 9 or later
struct thisStructureIsOnlyAvailableAfterIOS9{}

Comments

Popular posts from this blog

Setting up a playground

Go to another page