Bird
0
0

What is the main purpose of using @Model in SwiftUI?

easy📝 Conceptual Q11 of 15
iOS Swift - Local Data Persistence
What is the main purpose of using @Model in SwiftUI?
ATo mark a class as a data container for app state
BTo create a user interface element
CTo define a function for navigation
DTo style text in the app
Step-by-Step Solution
Solution:
  1. Step 1: Understand the role of @Model

    @Model is used to mark a class that holds data for the app, making it a data container.
  2. Step 2: Differentiate from UI or styling

    @Model does not create UI elements or style text; it only defines data structures.
  3. Final Answer:

    To mark a class as a data container for app state -> Option A
  4. Quick Check:

    @Model = data container [OK]
Quick Trick: Remember: @Model is for data, not UI or styling [OK]
Common Mistakes:
  • Thinking @Model creates UI components
  • Confusing @Model with styling attributes
  • Assuming @Model defines functions

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More iOS Swift Quizzes