JAL JAL -5 years ago 773
iOS Question

Using NSUserDefaults with Xcode 8 and iOS 10

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)

Answer Source

NSUserDefaults has been renamed to UserDefaults. standardUserDefaults() has been renamed to standard().

let defaults = UserDefaults.standard()

This now works.

Xcode Documentation:

Xcode Docs

Pre-release documentation link.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download