Commit 0a8024a7 authored by Jose Blaya's avatar Jose Blaya
Browse files

Method to retrieve all values

parent 6fad6736
......@@ -32,11 +32,21 @@ public extension EnumsBuilder where Self: RawRepresentable, Self.RawValue == Int
}
static func countCases() -> Int {
var numCases = 0
while Self(rawValue: numCases) != nil {
while Self(rawValue: numCases) != nil || numCases == 0 {
numCases += 1
}
return numCases
}
static func allValues() -> [Self] {
var allValues: [Self] = []
for value in 0...self.countCases() {
if let value = Self(rawValue: value) {
allValues.append(value)
}
}
return allValues
}
}
public extension EnumsBuilder where Self: RawRepresentable, Self.RawValue == String {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment