Bird
0
0

Given the model definition:

medium📝 Predict Output Q13 of 15
iOS Swift - Local Data Persistence
Given the model definition:
@Model class Task { var title: String; var done: Bool }

What is the output of this code?
let task = Task(title: "Buy milk", done: false)
print(task.done)
Atrue
Bfalse
Cnil
DCompilation error
Step-by-Step Solution
Solution:
  1. Step 1: Understand model initialization

    The Task model is initialized with done set to false (@Model synthesizes the initializer).
  2. Step 2: Print the done property value

    Printing task.done outputs the Boolean value false.
  3. Final Answer:

    false -> Option B
  4. Quick Check:

    task.done = false [OK]
Quick Trick: Check property values passed during initialization [OK]
Common Mistakes:
  • Assuming default true value for done
  • Expecting nil instead of false
  • Thinking @Model changes property defaults

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More iOS Swift Quizzes