Answers for "how to get enum raw value swift"

3

enum from raw value swift

enum TestEnum: String {
  case Name = "Name"
  case Gender = "Gender"
  case Birth = "Birth Day"
}

let name = TestEnum(rawValue: "Name")!       //Name
let gender = TestEnum(rawValue: "Gender")!   //Gender
let birth = TestEnum(rawValue: "Birth Day")! //Birth
Posted by: Guest on December-19-2020
1

enum raw value swift

enum numbers: Int {
 case one = 1, two, three, four
}

let num = numbers.one
print(num.rawValue) // Output: 1
Posted by: Guest on December-31-2020

Code answers related to "Swift"

Browse Popular Code Answers by Language