Skip to main content

One post tagged with "UserDefaults"

View All Tags

(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:

  1. SwiftyUserDefaults: "Modern Swift API for NSUserDefaults"
  2. Defaults: "Swifty and modern UserDefaults"
  3. Foil: "A lightweight property wrapper for UserDefaults done right"