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
func sceneWillResignActive(_ scene: UIScene) { | |
var shortcutItems = UIApplication.shared.shortcutItems ?? [] | |
if shortcutItems.isEmpty { | |
shortcutItems += [ | |
UIApplicationShortcutItem(type: "Test Type 0", localizedTitle: "Test Title 0"), | |
UIApplicationShortcutItem(type: "Test Type 1", localizedTitle: "Test Title 1") | |
] | |
} else { | |
if let mutableShortcutItem = shortcutItems.first?.mutableCopy() as? UIMutableApplicationShortcutItem { | |
mutableShortcutItem.type = "Updated Type 0" |
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
func windowScene(_ windowScene: UIWindowScene, performActionFor shortcutItem: UIApplicationShortcutItem, completionHandler: @escaping (Bool) -> Void) { | |
let alertController = UIAlertController(title: "Alert", message: "performActionFor \(shortcutItem.type)", preferredStyle: .alert) | |
alertController.addAction(UIAlertAction(title: "Dismiss", style: .cancel, handler: nil)) | |
window?.rootViewController?.present(alertController, animated: true, completion: nil) | |
} |
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
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { | |
let contentView = ContentView() | |
if let windowScene = scene as? UIWindowScene { | |
let window = UIWindow(windowScene: windowScene) | |
window.rootViewController = UIHostingController(rootView: contentView) | |
self.window = window | |
window.makeKeyAndVisible() | |
} | |
if let shortcutItem = connectionOptions.shortcutItem { |
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
from datetime import datetime | |
datetime(2020, 1, 10, 13, 2, 0) | |
# a datetime object by specifying year, month, day, hour, minute, second | |
datetime.today() | |
# a datetime object with current date and time | |
datetime.now() | |
# the same as above when tz is None | |
datetime.utcnow() | |
# the same as above, but in the UTC (Coordinated Universal Time) |