SwiftUI Data Persistence w/AppStorage and SceneStorage Flashcards

1
Q

What is the @SceneStorage property wrapper used for?

A

To store small amounts of data within the scope of individual app scene instances.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the @SceneStorage property wrapper ideal for?

A

Saving and restoring the state of a screen between app launches.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How is Scene storage declared?

A

Using the @SceneStorage property wrapper together with a key string value which is used internally to store the associated value.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Scene storage declaration syntax

A

@SceneStorage(“keyName”) var keyName: String = “”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What does the @SceneStorage property wrapper do?

A

Allows each individual scene within an app to have its own copy of stored data.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the @AppStorage property wrapper used for?

A

To store data that is universally available throughout the entire app.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

App Storage is built on top of _____

A

UserDefaults

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What was “UserDefaults” provided for?

  1. Primary use
  2. Secondary use
A
  1. As a way for apps to access and store default user preferences (such as language preferences or color choices).
  2. Can also be used to store small amounts of data need by the app in the form of key-value pairs.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

App storage declaration syntax

A

@AppStorage(“mystore”) var mytext: String = “”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

As with scene storage, the @AppStorage property wrapper requires a 1. ____ _____ to serve as a 2. _____

A
  1. String value

2. Key

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

By default, where will data be stored?

A

In the standard UserDefaults storage.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What do App Groups do?

A

They allow apps to share data with other apps and targets within the same group.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Where are app groups enabled and configured?

A

Within the Xcode project Signing and Capabilities screen.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What data types do the @AppStorage and @SceneStorage property wrappers support?

A

Bool, Int, Double, String, URL, and Data types.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly