Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect iOS11 programmatically in Swift?

Tags:

swift

ios11

I saw in the WWDC video that there's some new swift function to detect iOS 11 availability.

How do I detect iOS11 with Swift?

like image 216
Alex Stone Avatar asked Sep 11 '25 04:09

Alex Stone


2 Answers

Swift 3:

if #available(iOS 11.0, *) {
  // Running iOS 11 OR NEWER
} else {
  // Earlier version of iOS
}

More information is available in Declaration Attributes section of Apple's Swift Programming Guide.

like image 140
Alex Stone Avatar answered Sep 13 '25 08:09

Alex Stone


Objective C:

if (@available(iOS 11, *)) {
  // Running iOS 11 OR NEWER
} else {
  // Earlier version of iOS
}
like image 35
Sunil Targe Avatar answered Sep 13 '25 07:09

Sunil Targe