0

I'm trying to set a class constant depending on the current running macOS version.

class MyClass {
 // only when macOS 10.15
 let constant = 1

 // only when macOS 11
 let constant = 2
}

@available only capsules classes or functions while #if only works on compile time and if #available(macOS 11.0, *) works only inside functions.

Is there a way to realise this without defining the constant as a variable and set it in the init of the class?

Mike Nathas
  • 1,187
  • 1
  • 9
  • 25
  • 1
    To get the OS version at runtime see https://stackoverflow.com/questions/24503001/check-os-version-in-swift – vadian Sep 18 '21 at 06:13

0 Answers0