Skip to content

Instantly share code, notes, and snippets.

@mkeremkeskin
Created November 10, 2020 13:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mkeremkeskin/87d2f4f147b3a0c8183f3b72f4020423 to your computer and use it in GitHub Desktop.
Save mkeremkeskin/87d2f4f147b3a0c8183f3b72f4020423 to your computer and use it in GitHub Desktop.
public enum FilterType: String, BaseSelectionType, CaseIterable {
case colorDocument = "colorDocumentLocalization"
case blackAndWhite = "blackAndWhiteLocalization"
case colorPhoto = "colorPhotoLocalization"
case greyscale = "greyscaleLocalization"
case general = "generalLocalization"
func localizedString() -> String {
return NSLocalizedString(self.rawValue, comment: "")
}
init(backendId: Int) {
switch backendId {
case 11: self = .colorDocument
case 22: self = .blackAndWhite
case 33: self = .colorPhoto
case 44: self = .greyscale
default: self = .general
}
}
}
// custom initialization example
let type = FilterType(id: 22)
print(type.localizedString())
//prints Black and White
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment