Bird
0
0

What will happen if you call save() on an NSManagedObjectContext without any changes?

medium📝 Predict Output Q5 of 15
iOS Swift - Local Data Persistence
What will happen if you call save() on an NSManagedObjectContext without any changes?
ANothing happens, save returns true immediately
BAn error is thrown
CThe context resets
DThe app crashes
Step-by-Step Solution
Solution:
  1. Step 1: Understand save() behavior

    Calling save() on a context with no changes does nothing and returns true immediately.
  2. Step 2: Check error or crash possibilities

    No error or crash occurs because no changes need saving.
  3. Final Answer:

    Nothing happens, save returns true immediately -> Option A
  4. Quick Check:

    Save without changes = no-op success [OK]
Quick Trick: Save without changes returns success immediately [OK]
Common Mistakes:
  • Expecting error on empty save
  • Thinking context resets automatically
  • Assuming crash on save

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More iOS Swift Quizzes