Last active
November 29, 2016 02:58
-
-
Save tgunr/85c66e2a0bb291986b8a712a9b4608bb to your computer and use it in GitHub Desktop.
enum
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
enum ShortcutIdentifier: String { | |
case Start | |
case Stop | |
case Share | |
init?(fullType: String) { | |
guard let last = fullType.components(separatedBy: ".").last else { return nil } | |
self.init(rawValue: last) | |
} | |
var type: String { | |
return Bundle.main.bundleIdentifier! + ".\(self.rawValue)" | |
} | |
} | |
class MainViewController: UIViewController { | |
var shortcutItem: UIApplicationShortcutItem? | |
override func viewDidAppear(_ animated: Bool) { | |
super.viewWillAppear(animated) | |
self.neighborPickerView.reloadAllComponents() | |
let selectedShortcutItem = shortcutItem | |
if selectedShortcutItem != nil { | |
switch (selectedShortcutItem) { | |
case ShortcutIdentifier.Start.type: | |
Error:(119, 43) expression pattern of type 'String' cannot match values of type 'UIApplicationShortcutItem?' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment