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

51 lines
1.2 KiB
Swift
Raw Normal View History

2018-10-20 14:54:59 +00:00
//
// 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
}
}
2022-11-23 16:35:25 +00:00
var isStateRestorationActivity: Bool {
get {
(userInfo?["isStateRestorationActivity"] as? Bool) ?? false
}
set {
if userInfo == nil {
userInfo = [:]
}
userInfo!["isStateRestorationActivity"] = newValue
}
}
convenience init(type: UserActivityType, accountID: String) {
2018-10-20 14:54:59 +00:00
self.init(activityType: type.rawValue)
self.userInfo = [
"accountID": accountID
]
2018-10-20 14:54:59 +00:00
}
func handleResume(manager: UserActivityManager) -> Bool {
2018-10-20 14:54:59 +00:00
guard let type = UserActivityType(rawValue: activityType) else { return false }
type.handle(manager)(self)
2018-10-20 14:54:59 +00:00
return true
}
}