First App.
Your learning space A little progress, every day
CHAPTER 05Lesson 16 of 36

Save information on the phone

An app should remember useful information after you close it.

In Codex6 min read & do
By the end of this lesson

Keep records between launches without adding an online service.

Let’s do this

  1. 1
    In Codex

    Decide what should be remembered

    List the information your app needs to keep, such as an item’s name, notes and completed status. Do not save information simply because you might want it someday.

  2. 2
    In Codex

    Use the phone’s own storage first

    Ask Codex to use suitable built-in Apple storage. SwiftData is Apple’s tool for saving structured records; small preferences may use a simpler store. Tell Codex not to add iCloud or a database subscription in this lesson.

  3. 3
    In Xcode

    Test a full close and reopen

    Create an item, change it, then stop the app in Xcode and run it again on the same simulator. Confirm the change is still there. Test deleting a record too.

  4. 4
    In Codex

    Understand what this does not protect against

    Local storage belongs to this installation. Deleting the app may remove its records, and a different simulator is a different device. If the information will matter, plan an export, backup or syncing route before people depend on it.

Xcode project window with Swift code and an iPhone preview showing a globe and Hello, world.View larger
Apple’s current guide uses this example. Your app’s name and version will differ.Screenshot source (opens a new tab)

A message for Codex

Make my first iPhone app remember the records needed for [describe the problem my app should solve] between launches. Use appropriate built-in Apple storage, such as SwiftData for structured records, and explain the choice. Keep the data on this device for now. Preserve existing records when changing the app. Add a meaningful persistence check and give me steps to test create, edit, delete, close and reopen. Explain what happens if the app is deleted.

What you should see

An item and its changes are still present after a full stop and restart on the same device. Deleted items stay deleted.

A couple of words, explained

Local storage
Information kept on this device rather than in an online service.
Database
An organised store of information the app can save and look up.

If you get stuck

Go at your own pace. There is no test to pass.

Checked 7 September 2026. Screens can change; the official guides below have the latest steps.

Saving data between launches