Lets say I have a sign up process that has 5 required elements. Each of these steps needs to be valid before the flow can be considered valid for submission. I feel like I've seen this done before with enums, where you |
different values together and when all of them are present, that represents a full/valid enum. How can I do that in Swift?
Asked
Active
Viewed 89 times
2
-
7BitMask seems what you are looking for: http://stackoverflow.com/questions/24066170/how-to-create-ns-options-style-bitmask-enumerations-in-swift/24066171 ? – Larme Aug 08 '16 at 15:25
-
3Take a look at the `OptionSet` (`OptionSetType` in Swift 2) [protocol documentation](https://developer.apple.com/reference/swift/optionset), which gives a nice usage example. – Hamish Aug 08 '16 at 15:30
-
1@Hamish please share that as the answer so I can mark it as the accepted answer. – Lizza Aug 08 '16 at 16:04
-
@Lizza I'm actually not too sure there's much that I can add that isn't already covered by the above [linked Q&A](http://stackoverflow.com/questions/24066170/how-to-create-ns-options-style-bitmask-enumerations-in-swift/24066171) (it has quite a lot of answers showing a few key usage examples). We can either close this question as a duplicate, or if there's something specific that you feel that Q&A doesn't cover, could you please edit your question with this specific request? I'd be happy to write an answer if you do :) – Hamish Aug 08 '16 at 17:11