What's the Swift equivalent of Objective-C's “#ifdef __IPHONE_11_0”?

后端 未结 5 1965
旧时难觅i
旧时难觅i 2021-02-05 06:50

I want to use Xcode 9 to add iOS 11 code to my project while keeping the option to compile the project with Xcode 8 which only supports iOS 10.

In Objective-C I can do t

5条回答
  •  终归单人心
    2021-02-05 07:42

    If you want to put the condition outside of the function, you could do it like below.

    @available(iOS 11.0, *)
    func functionName() {
     // function contents
    }
    

提交回复
热议问题