Skip to content

Instantly share code, notes, and snippets.

@Daemon-Devarshi
Last active August 2, 2017 14:06
Show Gist options
  • Save Daemon-Devarshi/1f8525298cd01f394400198f9747d106 to your computer and use it in GitHub Desktop.
Save Daemon-Devarshi/1f8525298cd01f394400198f9747d106 to your computer and use it in GitHub Desktop.
A protocol to be used to avoid hardcoding of reuse identifier (reference link: https://medium.com/swift-programming/uistoryboard-safer-with-enums-protocol-extensions-and-generics-7aad3883b44d)
protocol StoryboardIdentifiable {
static var storyboardIdentifier: String { get }
}
extension StoryboardIdentifiable where Self: UIViewController {
static var storyboardIdentifier: String {
return String(describing: self)
}
}
// Uncomment for Global Confirmance
// extension UIViewController: StoryboardIdentifiable { }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment