ubuntudroid
ubuntudroid

Reputation: 4009

Deprecate enum value in Swift

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.

Upvotes: 2

Views: 2223

Answers (1)

timbre timbre
timbre timbre

Reputation: 13996

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

Upvotes: 12

Related Questions