Skip to content

Instantly share code, notes, and snippets.

@tgunr
Last active November 29, 2016 02:58
Show Gist options
  • Save tgunr/85c66e2a0bb291986b8a712a9b4608bb to your computer and use it in GitHub Desktop.
Save tgunr/85c66e2a0bb291986b8a712a9b4608bb to your computer and use it in GitHub Desktop.
enum
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