【发布时间】:2016-12-12 13:37:02
【问题描述】:
我们将枚举用于一些基本的数据结构,如下所示:
enum Industry: String {
case Industry1 = "Industry 1", Industry2 = "Industry 2", Industry3 = "Industry 3"
static let allValues = [Industry1, Industry2, Industry3]
}
当我们将值存储在数据库中时,我们将它们存储为整数/数字。例如,Industry 的值可能是 2,即 Industry2。
如何将值 2 映射回枚举中的相关项?这样我就可以找回字符串值了?
【问题讨论】: