Bird
0
0

Which of the following is the correct way to declare a struct conforming to Identifiable with a constant id of type UUID?

easy📝 Syntax Q12 of 15
iOS Swift - Lists and Data Display

Which of the following is the correct way to declare a struct conforming to Identifiable with a constant id of type UUID?

struct Item: Identifiable {
    // Fill in the blank
}
Alet id: UUID = UUID()
Bvar id: UUID
Cvar id = UUID()
Dfunc id() -> UUID
Step-by-Step Solution
Solution:
  1. Step 1: Check property declaration for id

    The id must be a property, not a function.
  2. Step 2: Choose correct syntax with initialization

    Using let id: UUID = UUID() declares a constant id initialized with a new UUID, which is correct.
  3. Final Answer:

    let id: UUID = UUID() -> Option A
  4. Quick Check:

    Property with UUID value, not function [OK]
Quick Trick: id must be a property, not a function [OK]
Common Mistakes:
  • Declaring id as a function
  • Not initializing id
  • Using var without initialization

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More iOS Swift Quizzes