Skip to content

Instantly share code, notes, and snippets.

@wh1pch81n
Last active October 8, 2016 03:12
Show Gist options
  • Select an option

  • Save wh1pch81n/2eea1d3033734d317b4f1bdfb740aa1d to your computer and use it in GitHub Desktop.

Select an option

Save wh1pch81n/2eea1d3033734d317b4f1bdfb740aa1d to your computer and use it in GitHub Desktop.
An example of stringifying an enum string state
enum PageNames: String {
case sc🖍search = "MySearch"
var page_name: String {
return String(describing: self).replacingOccurrences(of: "🖍", with: "/")
}
}
PageNames.sc🖍search.rawValue // "MySearch"
PageNames.sc🖍search.page_name // "sc/search"
PageNames(rawValue: "MySearch")?.page_name // "sc/search"
PageNames(rawValue: "blh")?.page_name // nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment