Skip to content

Instantly share code, notes, and snippets.

@bencochran
Forked from asmallteapot/MonolithViewController.swift
Last active September 12, 2015 04:45
Show Gist options
  • Save bencochran/31aaf334fd32aebd293e to your computer and use it in GitHub Desktop.
Save bencochran/31aaf334fd32aebd293e to your computer and use it in GitHub Desktop.
Handling storyboard segues with enumerations in Swift
class MonolithViewController: UIViewController {
enum InnerSegueType: String {
case WebView
case Inspector
case Gadget = "SomeNameMismatch"
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
guard let identifier = segue.identifier,
let segueType = InnerSegueType(rawValue: identifier) else {
return
}
switch segueType {
case .WebView:
print("configure web view controller")
case .Inspector:
print("configure inspector")
case .Gadget:
print("configure gadget")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment