我正在尝试检查类型字符串是否等于数字字符串,但我似乎无法弄清如何将类型与枚举的rawValues进行比较。到目前为止,我已经做了这个:
然而,我不断收到“Enum case News not found in type String”的错误提示。
然而,我不断收到“Enum case News not found in type String”的错误提示。
enum ContentType: String {
case News = "News"
case Card = "CardStack"
func SaveContent(type: String) {
switch type {
case .News:
print("news")
case .Card:
print("card")
}
}
}
nil
的情况,因此你也可以使用字面字符串而不是枚举值。 - vadian