Updated by Владимир Самсонов 2020-10-08 View revision File by-ntpd.swift Added Side-by-side diff More Ignore whitespace Hide word diff +... + +import TrueTime + +// Фиксируем подходящее время (например запуск приложения): +let client = TrueTimeClient.sharedInstance +client.start() + +// Теперь вы можете использовать это вместо NSDate(): +let now = client.referenceTime?.now() + +// Чтобы заблокировать ожидание загрузки, используйте следующее: +client.fetchIfNeeded { result in + switch result { + case let .success(referenceTime): + let now = referenceTime.now() + case let .failure(error): + print("Error! \(error)") + } +} +...
Updated by Владимир Самсонов 2020-10-08 View revision File by-user-defaults.swift Added Side-by-side diff More Ignore whitespace Hide word diff +... + +let defaults = UserDefaults.standard +defaults.set(Date(), forKey: "lastRun") +let lastRun = defaults.object(forKey: "lastRun") as? Date + +...
Updated by Владимир Самсонов 2020-10-08 View revision File By GPS API.swift Deleted More Ignore whitespace Hide word diff -... - -#import CoreLocation - -... - -let gps = CLLocation() -print("gps time ", gps.timestamp) - -... File by-gps-api.swift Added Side-by-side diff More Ignore whitespace Hide word diff +... + +#import CoreLocation + +... + +let gps = CLLocation() +print("gps time ", gps.timestamp) + +...
Created by Владимир Самсонов 2020-10-08 View revision File By GPS API.swift Added Side-by-side diff More Ignore whitespace Hide word diff +... + +#import CoreLocation + +... + +let gps = CLLocation() +print("gps time ", gps.timestamp) + +...