Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func application(application: UIApplication, performActionForShortcutItem shortcutItem: UIApplicationShortcutItem, completionHandler: (Bool) -> Void) {
- let handeled = handleShortcutItem(shortcutItem)
- completionHandler(handeled)
- }
- private func handleShortcutItem(shortcutItem:UIApplicationShortcutItem) -> Bool {
- var handeledShortcutItem = false
- switch shortcutItem.type{
- case ShortcutTypes.first:
- if let tabBarController = self.window?.rootViewController as? UITabBarController {
- tabBarController.selectedIndex = 0
- }
- handeledShortcutItem = true
- break
- case ShortcutTypes.second:
- if let tabBarController = self.window?.rootViewController as? UITabBarController {
- tabBarController.selectedIndex = 1
- }
- handeledShortcutItem = true
- break
- case ShortcutTypes.third:
- if let tabBarController = self.window?.rootViewController as? UITabBarController {
- tabBarController.selectedIndex = 2
- }
- handeledShortcutItem = true
- break
- default:
- break
- }
- return handeledShortcutItem
- }
- func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
- // Override point for customization after application launch.
- var performShortcut = true
- if let shortcut = launchOptions?[UIApplicationLaunchOptionsShortcutItemKey] as? UIApplicationShortcutItem {
- self.selectedShortcutItem = shortcut
- performShortcut = false
- }
- return performShortcut
- }
- func applicationDidBecomeActive(application: UIApplication) {
- if let shortcut = selectedShortcutItem {
- handleShortcutItem(shortcut)
- }
- selectedShortcutItem = nil
- // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement