Skip to content

Instantly share code, notes, and snippets.

@russell-archer
Created October 9, 2018 00:14
Show Gist options
  • Save russell-archer/9a6e51c7a883338c437c235202127bc7 to your computer and use it in GitHub Desktop.
Save russell-archer/9a6e51c7a883338c437c235202127bc7 to your computer and use it in GitHub Desktop.
ShowRandomColor. Add support for the user tapping a shortcut
//
// AppDelegate.swift
// ShowRandomColor
//
// Created by Russell Archer on 05/10/2018.
// Copyright © 2018 Russell Archer. All rights reserved.
//
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication,
continue userActivity: NSUserActivity,
restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
if userActivity.interaction?.intent is ShowRandomColorIntent {
let viewController = window?.rootViewController as! ViewController
viewController.setColor()
return true
}
return false
}
// Other methods not shown for brevity
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment