NSUserDefaults
no longer appears to be a class in the iOS 10 SDK:
let defaults = NSUserDefaults.standardUserDefaults()
This fails to compile. Was this class removed?
(This is a canonical Q&A pair to prevent the flood of duplicate questions)
NSUserDefaults
has been renamed to UserDefaults
. standardUserDefaults()
has been renamed to standard()
.
let defaults = UserDefaults.standard
This now works.
Pre-release documentation link.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With