2

Is there a way to get the current platform of the device? I'm hoping for a better way than to do something like this:

let platform: String

#if os(iOS)
platform = "iOS"
#elseif os(watchOS)
platform = "watchOS"
#elseif os(tvOS)
platform = "tvOS"
#elseif os(macOS)
platform = "macOS"
#else
platform = "unknown"
#endif

Is there a better way to do this?

TruMan1
  • 33,665
  • 59
  • 184
  • 335

0 Answers0