How to use a variable in @available(macOS ver, *)

Hi Experts,

How to use a variable in @available(macOS ver, *), I do not want to hard code like this:
if (@available(macOS 10.16, *))
{
//...
}
Thanks a lot!
Answered by Android2Test in 650206022
[[NSProcessInfo processInfo] operatingSystemVersion] 

How to use a variable in @available(macOS ver, *)

No way.

 I do not want to hard code like this

Then you cannot use @available in your app.


Some attributes might get more useful if you can use variables in them.
But I do not think @available can be a good example. When you write some code which needs @available, it is strongly dependent on a specific version. Hiding such info useing variables would not be a good abstraction.

If you want to hear opinions from more developers, you should better visit https://forums.swift.org .
Thanks OOPer, I just wan to compare the app path for different OS version:

std::vector<Config> gConfigs = { {@APP_PATH, @OSVersion}, ...};
...

In the compare:
if (@available(@OSVersion, *) {...}

Is there any avaiable API?
Accepted Answer
[[NSProcessInfo processInfo] operatingSystemVersion] 
How to use a variable in @available(macOS ver, *)
 
 
Q