Home > OS >  Deprecate enum value in Swift
Deprecate enum value in Swift

Time:03-05

Is it possible to mark an enum value in Swift as deprecated?

I tried

enum RelativeDays {
   case today, tomorrow, @available(*, deprecated, message: "Don't live in the past! Cherish the moment and look forward to the future!") yesterday
}

But I get a compilation error saying that an identifier is expected where the annotation is.

CodePudding user response:

I think it's just the syntax:

enum RelativeDays {
   case today
   @available(*, deprecated, message: "Don't live in the past! Cherish the moment and look forward to the future!")
   case tomorrow
}

works: enter image description here

  • Related