Quantcast
Channel: How to store date in userdefaults? - Stack Overflow
Browsing all 5 articles
Browse latest View live

Answer by Ihwan for How to store date in userdefaults?

you can always create an extension for saving and retrieving the date in userdefault. here the example code:import Foundationextension UserDefaults { func set(date: Date?, forKey key: String){...

View Article



Answer by jameshfisher for How to store date in userdefaults?

The following saves a Date object as a Double (a.k.a. TimeInterval). This avoids any date formatting. Formatting can lose precision, and is unnecessary since the string is not intended for users to...

View Article

Answer by Joakim Danielson for How to store date in userdefaults?

If you only want to display the date value you can convert and store it as string otherwise you convert/format it after you have read it, either way you should make sure you use the same type when...

View Article

Answer by john elemans for How to store date in userdefaults?

Your problem is that you are retrieving NSDate from the user default storage and then trying to assign them to a String (formatteddate).Try this; formatteddate = formatter.string(from: RetrivedDate as...

View Article

How to store date in userdefaults?

I'd like to record the history of her entry into the textfield. I intend to register this with UserDefaults. But when I try to save it with UserDefaults, "cannot assign value of type 'nsdate'?'to type...

View Article

Browsing all 5 articles
Browse latest View live




Latest Images