JHZ JHZ - 1 year ago 105
iOS Question

Does availability matter for Swift enums?

Swift requires me to add an

annotation when using
, an enumeration that was added in iOS 10.
is just a replacement for
, and using the new replacement is fine in C-land, since enums are just integers.

If I want to support iOS 9, is this also safe in Swift 2.3, or should I stick with the deprecated versions?

Answer Source

Yes, availability matters for all symbols in the SDK. The issue isn't that the numbers aren't available in iOS versions less than 10, but the actual CBManagerState symbol is not available.

If you are targeting iOS 9, use the symbols and enums available to you in that SDK (what you are calling the "deprecated" types). If you specifically want to support an iOS 10 feature, use an availability check for the iOS 10 feature or version and fall back on iOS 8/9 functionality if the conditions of your check are not met.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download