(2022/04/01: updated and expanded)
NSUserDefaults → UserDefaults
In the beginning, when Cocoa was hot (circa 2001), there was already NSUserDefaults, a thoughtful API for the seemingly simple task of persisting preference settings.
Swift (since 2014) gave it a cleaner name (UserDefaults, without the NS prefix), but it also created new expectations that the plain old class was not delivering:
- strong type checking
- easy value types usage
- modern Swiftness, etc.
This is where Swiftified UsersDefaults libraries come in. Here we look at a few of them:
- SwiftyUserDefaults: "Modern Swift API for NSUserDefaults"
- Defaults: "Swifty and modern UserDefaults"
- Foil: "A lightweight property wrapper for UserDefaults done right"