美文网首页
Swift中rawValue的作用

Swift中rawValue的作用

作者: isnow | 来源:发表于2020-09-24 17:44 被阅读0次

    rawValue 用于swift中的enum(枚举),用于取枚举项的原始值,例如:

    enum Category: String, CaseIterable, Codable, Hashable {

            case featured = "Featured"

            case lakes = "Lakes"

            case rivers = "Rivers"

            case mountains = "Mountains"

        }

    Category.lakes.rawValue 就是 "Lakes"


    相关文章

      网友评论

          本文标题:Swift中rawValue的作用

          本文链接:https://www.haomeiwen.com/subject/anktuktx.html