Reputation: 1044
I used this code to store to UserDefaults. I want to know, how i can set time expire?
static func _getByKey(_ key: String) -> Any? {
UserDefaults.standard.string(forKey: key)
}
static func _setByKey(_ key: String, _ val: Any) {
UserDefaults.standard.set(val, forKey: key)
}
Upvotes: 0
Views: 844
Reputation: 100503
There is no short way to do so , you need to store a timestamp and check it with the current one every app open to clear the keys / not
Upvotes: 1