I have an enum holding several values:
enum {value1, value2, value3} myValue;
In a certain point in my app, I wish to check which value of
Below is a example of Enum Struct that is Objective-C friendly in the event you need to use Swift Code in Legacy projects written in Objective-C.
Example:
contentType.filename. toString()
returns "filename"
contentType.filename. rawValue
returns the Int Value, 1 (since its the second item on struct)
@objc enum contentType:Int {
//date when content was created [RFC2183]
case creationDate
//name to be used when creating file [RFC2183]
case filename
//whether or not processing is required [RFC3204]
case handling
//date when content was last modified [RFC2183]
case modificationDate
//original field name in form [RFC7578]
case name
//Internet media type (and parameters) of the preview output desired from a processor by the author of the MIME content [RFC-ietf-appsawg-text-markdown-12]
case previewType
//date when content was last read [RFC2183]
case readDate
//approximate size of content in octets [RFC2183]
case size
//type or use of audio content [RFC2421]
case voice
func toString() -> String {
switch self {
case .creationDate:
return "creation-date"
case .filename:
return "filename"
case .handling:
return "handling"
case .modificationDate:
return "modification-date"
case .name:
return "name"
case .previewType:
return "preview-type"
case .readDate:
return "read-date"
case .size:
return "size"
case .voice:
return "voice"
}
}//eom
}//eo-enum