Skip to content

Instantly share code, notes, and snippets.

@whiskey
Created July 31, 2015 08:27
Show Gist options
  • Select an option

  • Save whiskey/4def64050c7afdadb6c3 to your computer and use it in GitHub Desktop.

Select an option

Save whiskey/4def64050c7afdadb6c3 to your computer and use it in GitHub Desktop.
enum FormSection: Int {
case Header, Section1, Section2, Section2, Section3, Summary
static let identifiers = [
Header: "header",
Section1: "s1",
Section2: "s2",
Section3: "s3",
Summary: "summary"
]
static let sectionHeaders = [
Section1: NSLocalizedString("foo1", comment: "bar1"),
Section2: NSLocalizedString("foo2", comment: "bar2"),
Section3: NSLocalizedString("foo3", comment: "bar3")
Summary: NSLocalizedString("header.summary", comment: "lalala"),
]
static var count:Int { return 5 }
func identifier() -> String {
if let id = FormSection.identifiers[self] {
return id
} else {
return "undefined"
}
}
func headerTitle() -> String? {
if let string = FormSection.sectionHeaders[self] {
return string
} else {
return nil
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment