Oleg G.
Oleg G.

Reputation: 598

How to use @available with class variables

How would I create a specific iOS 14 class variable?

I tried these two forms with a @available property builder:

struct Blabla {
    @available(iOS 14.0, *)
    @Namespace private var animation
}
struct Blabla {
    @available(iOS 14.0, *) @Namespace private var animation
}

but it shows this error: 'Namespace' is only available in iOS 14.0 or newer.

Upvotes: 2

Views: 917

Answers (2)

Oleg G.
Oleg G.

Reputation: 598

Well, the answer is no, we can't :(

Only at function or class level. In my case, I duplicated the class and renamed the previous one to MyClass13. And I put a if @available where i need to call it.

Thanks!

Upvotes: 3

Giovanni Gaffé
Giovanni Gaffé

Reputation: 56

I usually set availability like so after cou can store some static properties and shared ll inside your app

Upvotes: 0

Related Questions