Persistence: UserDefaults

Spring 2019 & Fall 2019 Additional Topic

What is Persistence?

In short, data persistence is keeping the data you are working with around. This means that the same data can be retrieved without being altered when the user closes and then re-opens the app.

Achieving Persistence in iOS

There are several ways to achieve persistence in iOS, including:

  1. UserDefaults

  2. CoreData

  3. CloudKit

  4. UIDocument

In the course, we focus on UserDefaults, which is used to achieve lightweight persistence, e.g. to store small amounts of data.

Lecture Slides

Lecture Demos

Persistence has been an additional topic for a few different semesters, so there's a few demos available!

Spring 2020 Demo

The following demo introduces SnapKit alongside using UserDefaults!

Spring 2019 Demo

The following demo involves using UserDefaults with custom classes by conforming the class to Codable.

Fall 2019 Demo

The following demo introduces SnapKit alongside using UserDefaults!

Last updated