Module Quiz: Project Functionality :iOS App Capstone (Meta iOS Developer Professional Certificate) Answers 2026
Question 1
Given the following code from server response, which struct would be needed to properly decode it into Swift format?
❌ struct JSONMenu:: Codable { ... }
✅ struct JSONMenu: Codable { let list: [FoodItem] }
❌ struct ListMenu: Codable { ... }
Explanation:
JSON me list array hai jisme name, price, aur description keys hain. Struct me exact key names match hone chahiye, isliye description hi sahi hai, dishDescription nahi.
Question 2
What operations does the following code perform?
✅ Creates dishes in the Dish entity with data from MenuItems.
❌ Deletes MenuItems that do not have corresponding Dish entities in the database.
❌ Creates new MenuItems from existing Dish entities.
❌ Deletes Dish entities that do not have corresponding MenuItems in the array.
Explanation:
Code loop me Dish objects create kar raha hai using MenuItem data.
Question 3
How can you use the NSPredicate class to correctly retrieve entries that contain the term “Café au Lait” while ignoring case and accents? (Select all)
✅ NSPredicate(format: “name CONTAINS[cd] %@”, “Café au Lait”)
✅ NSPredicate(format: “%K CONTAINS[cd] %@”, “name”, “CAFE AU LAIT”)
❌ NSPredicate(format: “name CONTAINS %@”, “Café au Lait”)
❌ NSPredicate(format: “name == %@”, “Café au Lait”)
Explanation:[c] → case-insensitive[d] → diacritic-insensitive (accent ignore)
Question 4
Which of the following code blocks is correct for fetching from a Dish entity without sorting or filtering?
✅ Option 1
❌ Option 2
❌ Option 3
Explanation:sorDescriptors: [] + NSPredicate(value: true) means fetch everything without filter or sort.
Question 5
Please describe what the following code does:
✅ Initializes an NSSortDescriptor with key name, ascending order, and localized string comparison.
❌ Initializes descending order sort.
❌ Creates an NSManagedObject instance.
Explanation:
Code sirf sorting logic define karta hai, object create nahi karta.
Question 6
What is happening in this line of code?
❌ Case-insensitive predicate
❌ Case-sensitive predicate
✅ Case-insensitive & diacritic-insensitive predicate searching fullName for “Jane Doe”.
Explanation:[d] → diacritics ignoredCONTAINS → substring match
Question 7
Which predicate format is correct?
✅ NSPredicate(format: "(%K < %@) AND (customerName CONTAINS[cd] %@)", "productPrice", price, partialName)
❌ %K missing key string
❌ Invalid placeholder usage
Explanation:%K requires a key name as String, not a variable.
Question 8
How can you search for Dish objects with title containing specific text?
✅ NSPredicate(format: “title CONTAINS[cd] %@”, searchText)
❌ MATCHES (regex based)
❌ LIKE with wrong key
❌ Case-sensitive contains
Explanation:
Best practice: CONTAINS[cd] for user search.
Question 9
What is the role of NSManagedObjectContext in this code?
✅ To manage the creation and modification of Dish objects based on MenuItem objects.
❌ Manage MenuItem creation
❌ Convert Dish into MenuItem
Explanation:NSManagedObjectContext Core Data ka main workspace hota hai.
Question 10
Which Core Data base class helps reduce boilerplate code?
❌ NSString.localizedCompare
❌ NSPredicate
✅ NSManagedObject
❌ NSSortDescriptor
Explanation:NSManagedObject subclass se automatic Core Data handling milti hai.
🧾 Summary Table
| Q# | Correct Answer(s) | Concept |
|---|---|---|
| 1 | JSONMenu + FoodItem | JSON decoding |
| 2 | Create Dish entities | Core Data insert |
| 3 | CONTAINS[cd] | Accent & case ignore |
| 4 | Predicate true | Fetch all |
| 5 | NSSortDescriptor | Sorting |
| 6 | Diacritic insensitive | NSPredicate |
| 7 | %K usage | Predicate keys |
| 8 | CONTAINS[cd] | Text search |
| 9 | Context role | Core Data |
| 10 | NSManagedObject | Boilerplate reduction |