Tusker/Tusker/Shortcuts/NSUserActivity+Extensions.s...

36 lines
826 B
Swift

//
// NSUserActivity+Extensions.swift
// Tusker
//
// Created by Shadowfacts on 10/19/18.
// Copyright © 2018 Shadowfacts. All rights reserved.
//
import Foundation
extension NSUserActivity {
var displaysAuxiliaryScene: Bool {
get {
(userInfo?["displaysAuxiliaryScene"] as? Bool) ?? false
}
set {
if userInfo == nil {
userInfo = [:]
}
userInfo!["displaysAuxiliaryScene"] = newValue
}
}
convenience init(type: UserActivityType) {
self.init(activityType: type.rawValue)
}
func handleResume(manager: UserActivityManager) -> Bool {
guard let type = UserActivityType(rawValue: activityType) else { return false }
type.handle(manager)(self)
return true
}
}