Forked from asmallteapot/MonolithViewController.swift
Last active
September 12, 2015 04:45
-
-
Save bencochran/31aaf334fd32aebd293e to your computer and use it in GitHub Desktop.
Handling storyboard segues with enumerations in Swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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