I want to execute a code block only on devices running with an OS older than iOS8
. I can\'t do:
if #available(iOS 8.0, *) == false {
doFoo()
Seems it's the best solution, before Swift2 you had to use other methods such as using ready-to-use classes wrote by individuals. But that's fine, you can set a variable in viewDidLoad()
and use it to detect the older devices:
var isNewerThan8: Bool = false
func viewDidLoad(){
if #available(iOS 8.0, *) {
isNewerThan8 = true
} else {
isNewerThan8 = false
}
}
func myFunction(){
if isNewerThan8 {
//foo
}else{
//boo
}
}