Bird
0
0

What is the purpose of marking a class with @Model in SwiftData?

easy📝 Conceptual Q11 of 15
iOS Swift - Local Data Persistence
What is the purpose of marking a class with @Model in SwiftData?
AIt disables saving data for that class.
BIt makes the class visible only to the current view.
CIt tells SwiftData to manage and save instances of that class automatically.
DIt converts the class into a SwiftUI view.
Step-by-Step Solution
Solution:
  1. Step 1: Understand the role of @Model

    The @Model attribute marks a class as a data model for SwiftData to manage persistence.
  2. Step 2: Recognize automatic data management

    SwiftData automatically saves and tracks changes for classes marked with @Model.
  3. Final Answer:

    It tells SwiftData to manage and save instances of that class automatically. -> Option C
  4. Quick Check:

    @Model means automatic data management [OK]
Quick Trick: Remember: @Model means SwiftData saves your data class [OK]
Common Mistakes:
  • Thinking @Model creates a UI component
  • Assuming @Model disables saving
  • Confusing @Model with view modifiers

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More iOS Swift Quizzes