This file contains hidden or 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
| - (void)applicationDidEnterBackground:(UIApplication *)application { | |
| @weakify(self); | |
| self.backgroundTaskIdentifier = [application beginBackgroundTaskWithExpirationHandler:^{ | |
| @strongify(self); | |
| [application endBackgroundTask:self.backgroundTaskIdentifier]; | |
| self.backgroundTaskIdentifier = UIBackgroundTaskInvalid; | |
| }]; | |
| } | |
| - (void)testApplicationDidEnterBackgroundExpirationHandler { |
This file contains hidden or 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
| import Foundation | |
| func machToNanoseconds(_ mach: UInt64) -> Double { | |
| struct Static { | |
| static var info: mach_timebase_info = { | |
| var info = mach_timebase_info() | |
| mach_timebase_info(&info) | |
| return info | |
| }() | |
| } |
This file contains hidden or 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
| extension Optional { | |
| // `then` function executes the closure if there is some value | |
| func then(_ handler: (Wrapped) -> Void) { | |
| switch self { | |
| case .some(let wrapped): return handler(wrapped) | |
| case .none: break | |
| } | |
| } | |
| } |
This file contains hidden or 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
| // | |
| // WatchSessionManager.swift | |
| // WatchConnectivityDemo | |
| // | |
| // Created by Natasha Murashev on 9/3/15. | |
| // Copyright Β© 2015 NatashaTheRobot. All rights reserved. | |
| // | |
| import WatchConnectivity |
This file contains hidden or 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
| import Foundation | |
| func bindData() { | |
| struct Static { | |
| static var token: dispatch_once_t = 0 | |
| } | |
| dispatch_once(&Static.token) { | |
| self.title = self.viewModel.title | |
| self.navigationItem.title = self.viewModel.title | |
| self.viewModel.viewPresenter = self |

