Posts

Showing posts from December, 2019

enum in Swift of Type String

enum in Swift of Type String Many a times we would like to use enum to store text value's or may be even better to store fixed messages. Like in below case ,  we are creating a enumeration called "StringMessages" and "raw Values" are defined to be of Type "String"     enum StringMessages : String {        case emptyText = "InputText is Empty"        case nonEmptyText = "Input Text is not Empty"    } The only requirement here is the Raw Value should be unique. Raw Values can be String , characters , integer or floating point number types. Raw Values of this enum can be accessed using StringMessages.emptyText.rawValue or StringMessages.nonEmptyText.rawValue.