Skip to main content

UserDefaults in Swift

Kenneth P. Wong
software craftsman

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

Kase 3 on iOS 15

(last updated: 2022/04/26)

Kase 3 was designed for iOS1 13, and it has been updated numerous times to work well with later releases of iOS 13 and 14.

Kase 4 will be the recommended version of Kase for iOS 15 and greater. This post will document how the older Kase 3 works under iOS 15.

Footnotes

  1. iOS here refers to both iOS and iPadOS,

WISD '21 Redesign ⓤ

updated: 2021/01/01 [^ⓤ]

var year = 2020 2021

🎄 Merry Christmas and Happy New Year! 🙏🇺🇸

This is the 2021 new design for WISD.com. It should be live at 2:30 PM (Pacific Time) on this very first day of 2021.

Please pardon any rough edges for the moment...