int to enum:
public enum LanguageCode : Int{
case ko
case en
case ja
case zhcn
case zhtw
case th
case vi
case es
case pt
case fr
case de
case ru
var description: String {
return String(describing: self)
}
}
print(languageCode.rawValue) //0
print(languageCode.description) //ko
string to enum:
public enum LoginType: String {
case google="GOOGLE"
case facebook="FACEBOOK"
case apple="APPLE"
case guest="GUEST"
}
print(LoginType.google.rawValue) //GOOGLE
출처
https://stackoverflow.com/questions/28461133/swift-enum-both-a-string-and-an-int
https://stackoverflow.com/questions/24701075/swift-convert-enum-value-to-string