Reputation: 10348
I want to be able to only allow a api to be called if the version is 10.*. I know usually we use @available(10.0, *), but this means 10 and above.
How do i restrict 10 to <11?
Here is the persudo code:
if device is ios10 but less than 11 {
//Do this only for iOS10.*
}
Upvotes: 1
Views: 631
Reputation: 7106
You can use #available
instead of @available
, just tested this and it seems to do what you need:
if #available(iOS 11.0, *) {
// leave blank if you don't need to do anything here
} else if #available(iOS 10.0, *) {
print("You're on iOS 10!")
}
Upvotes: 4
Reputation: 704
You can use code:
let os = ProcessInfo().operatingSystemVersion
switch (os.majorVersion, os.minorVersion) {
case (10, 0): // iOS 10.0
// Do your code
default:
break // Some other version
}
Or if you want to use for all 10.* versions of OS, then simply skip minor version:
let os = ProcessInfo().operatingSystemVersion
if os.majorVersion == 10 {
// Do your code
}
Upvotes: 0