Bird
0
0

Which of the following is the correct way to create a fetch request for an entity named "Employee" in Swift?

easy📝 Syntax Q3 of 15
iOS Swift - Local Data Persistence
Which of the following is the correct way to create a fetch request for an entity named "Employee" in Swift?
Alet request = NSFetchRequest("Employee")
Blet request = NSFetchRequest(entityName: Employee)
Clet request = NSFetchRequest<Employee>(entityName: "Employee")
Dlet request = NSFetchRequest<Employee>()
Step-by-Step Solution
Solution:
  1. Step 1: Recall NSFetchRequest syntax

    Use generic type with entityName as a string: NSFetchRequest(entityName: "EntityName")
  2. Step 2: Check each option

    let request = NSFetchRequest(entityName: "Employee") matches correct syntax; others miss generics or quotes.
  3. Final Answer:

    let request = NSFetchRequest(entityName: "Employee") -> Option C
  4. Quick Check:

    Fetch request syntax = let request = NSFetchRequest(entityName: "Employee") [OK]
Quick Trick: Use generics and string entity name in fetch request [OK]
Common Mistakes:
  • Omitting generic type
  • Not quoting entity name
  • Using wrong initializer

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More iOS Swift Quizzes