oc使用swift中的枚举
Enumeration is a data type that allows you to define a list of possible values. An enum allows you to create a data type with those set of values so that they can be recognised consistently throughout your app.
枚举是一种数据类型,它允许您定义可能值的列表。 枚举允许您使用这些值集创建数据类型,以便可以在整个应用程序中一致地识别它们。
In other word: It is a group of related values 💯
换句话说:它是相关值的组合
声明一个枚举 (Declaring An Enumeration)
To declare an enumeration, you list out all the possible member values as cases:
要声明一个枚举,请列出所有可能的成员值作为案例:
You can simplify the code a bit by collapsing the case clauses down to one line, with each value separated by a comma:
您可以通过将case子句折叠为一行,并用逗号分隔每个值来稍微简化代码:
This code creates a new enumeration called Month
with 12 possible member values. The commonly accepted best practice is to start each member value with a lower case first letter, just like a property.
Ť他的代码创建了一个名为新的枚举Month
12倍可能的成员的值。 普遍接受的最佳做法是像属性一样,以