~/talk

UserDefaults: a wolf in sheep's clothing

Talkat iOS Conf SG 2025 · 2025-01-15..01-17· [swift]
slides:none on file

UserDefaults can silently return nil while the device is locked or during pre-warmed launches, allowing that temporary nil to overwrite real data; a reliable repro is live activity + reboot + open, which fails every time. Investigation uses file protection, checking isProtectedDataAvailable, switching to file-backed storage in an app group with atomic writes and a dispatch queue, coordinating cross-process access with NSFileCoordinator, caching in memory and observing disk changes. A Swift Codable + property‑wrapper library is built and published and it works to avoid the data-loss class.

AI-written summary · about

  1. 0:00Introduction
  2. 3:09UserDefaults data loss bug
  3. 8:01UserDefaults fails on locked devices
  4. 11:34Pre-warming risks
  5. 13:41Impact of UserDefaults data loss
  6. 15:44Workarounds for locked devices
  7. 17:30Safer alternative to UserDefaults
  8. 24:11Modern Swift storage design
  9. 30:12SwiftUI with custom storage
  10. 32:40Key takeaways
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.