0
0
iOS Swiftmobile~10 mins

Identifiable protocol in iOS Swift - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to make the struct conform to the Identifiable protocol by adding the required property.

iOS Swift
struct User: Identifiable {
  var [1]: Int
  var name: String
}
Drag options to blanks, or click blank then click option'
Aid
Bname
Cidentifier
Duid
Attempts:
3 left
💡 Hint
Common Mistakes
Using a property name other than 'id'.
Forgetting to add the 'id' property.
2fill in blank
medium

Complete the code to conform to Identifiable using a UUID as the id.

iOS Swift
struct Item: Identifiable {
  var [1] = UUID()
  var title: String
}
Drag options to blanks, or click blank then click option'
Auuid
Bidentifier
Cid
DitemId
Attempts:
3 left
💡 Hint
Common Mistakes
Using a different property name like 'uuid' or 'identifier'.
Not initializing the id property.
3fill in blank
hard

Fix the error in the struct by adding the missing Identifiable requirement.

iOS Swift
struct Product: Identifiable {
  var name: String
  var price: Double
  var [1]: Int
}
Drag options to blanks, or click blank then click option'
Auid
BproductId
Cidentifier
Did
Attempts:
3 left
💡 Hint
Common Mistakes
Using a different property name.
Not adding the id property at all.
4fill in blank
hard

Fill both blanks to create a struct conforming to Identifiable with a UUID id and a title.

iOS Swift
struct Task: Identifiable {
  var [1] = UUID()
  var [2]: String
}
Drag options to blanks, or click blank then click option'
Aid
Btitle
Cname
Duuid
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'uuid' instead of 'id' for the identifier.
Using 'name' instead of 'title' for the descriptive property.
5fill in blank
hard

Fill all three blanks to define a struct conforming to Identifiable with a UUID id, a name, and a description.

iOS Swift
struct Event: Identifiable {
  var [1] = UUID()
  var [2]: String
  var [3]: String
}
Drag options to blanks, or click blank then click option'
Aid
Bname
Cdescription
Dtitle
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'title' instead of 'name' or 'description'.
Not using 'id' as the identifier property.