Swift Evolution: Unavailability Condition

Batikan Sosun
Nov 16, 2020
Availability checking in Swift

In some cases, we need the negative of any conditions. At this point, if I describe that case as a basic instance;

if #available(iOS 13, *) {} else {
someOldStuff()
}

In this specific case, we don’t want that. The positive case is unnecessary and impairs code readability.

Swift’s new feature: Unavailability Condition

if #unavailable(iOS 13, *) {
someOldStuff()
}

Take a look at the negative availability.

https://github.com/apple/swift-evolution/blob/main/proposals/0290-negative-availability.md

--

--

Batikan Sosun

Tweeting tips and tricks about #swift #xcode #apple Twitter @batikansosun Weekly Swift Blogging