Recall & Review
beginner
What does the @Model attribute do in Swift?
The @Model attribute marks a Swift class as a data model that can be observed for changes and persisted automatically.Click to reveal answer
beginner
How do you define a simple model with @Model in Swift?
You create a class with the @Model attribute and define properties inside it. For example: <br><code>@Model class User { var id = UUID(); var name: String? }</code>Click to reveal answer
intermediate
Why use @Model instead of a regular class for data in Swift apps?Because @Model classes automatically support change tracking and persistence, making it easier to keep UI and data in sync.
Click to reveal answer
intermediate
Can @Model classes have relationships to other @Model classes?
Yes, @Model classes can reference other @Model classes to represent relationships like parent-child or one-to-many.
Click to reveal answer
beginner
What happens when you change a property inside an @Model class instance?The system automatically detects the change and updates any UI or storage that depends on that model instance.
Click to reveal answer
What keyword do you use to define a data model class that supports automatic persistence in Swift?
✗ Incorrect
@Model marks a class for automatic persistence and observation.
Which of these is true about @Model classes?
✗ Incorrect
@Model classes automatically track changes to their properties for UI and storage updates.
How do you declare a property inside an @Model class?
✗ Incorrect
Properties inside @Model classes are declared as variables with var.
Can @Model classes have relationships to other @Model classes?
✗ Incorrect
@Model classes can reference other @Model classes to model relationships.
What happens when you update a property in an @Model class instance?
✗ Incorrect
Changes to @Model properties automatically update UI and storage.
Explain how to define a simple data model using @Model in Swift and why it is useful.
Think about how @Model helps keep UI and data in sync.
You got /5 concepts.
Describe what happens behind the scenes when you change a property in an @Model class instance.
Consider how the app knows to refresh the screen or save data.
You got /4 concepts.