私は列挙型の中で関数を実行しようとしていますが、このコードを実行するとContentType.SaveContent("News")
エラーが続いています:Use of instance member on type 'ContentType'; did you mean to use a value of type 'ContentType' instead?
。なぜ型をStringに設定したのですか?enum内で関数を実行
enum ContentType: String {
case News = "News"
case Card = "CardStack"
func SaveContent(type: String) {
switch type {
case ContentType.News.rawValue:
print("news")
case ContentType.Card.rawValue:
print("card")
default:
break
}
}
}