I want to know the current time when the app is being terminated. Using this time, I want to do some calculation and store. How can I do this?
Asked
Active
Viewed 51 times
1 Answers
0
In Your AppDelegate.swift store time in user default in the following method and use them later
func applicationWillTerminate(_ application: UIApplication) {
let date = Date()
let df = DateFormatter()
df.dateFormat = "HH:mm:ss a"
let stringTime = df.string(from: date) // 11:35:59 AM
UserDefaults.standard.set(stringTime, forKey: "TerminatedTime")
}

Jaydip Finava
- 57
- 5