Browse Questions
  • Identifiable requires a type to have a unique id property.
  • Auto Layout calculates view frames at runtime by solving a system of linear equations defined by your constraints.
  • multipart/form-data is a content type used to send mixed data — like a file and text fields together — in a single request.
  • A diffable data source is a data source that you drive with immutable snapshots of Hashable identifiers instead of index-path callbacks, and it computes the inserts, deletes, and moves for you.

Answer: Identifiable requires a type to have a unique id property. SwiftUI uses this in ForEach and List to track which items are which across state changes — enabling correct animations and avoiding UI glitches.

Code Example:

struct Article: Identifiable {
    let id: UUID
    let title: String
}

// SwiftUI can now track each Article by id
List(articles) { article in
    Text(article.title)
}

// Without Identifiable — must provide keypath manually
List(articles, id: \.title) { article in
    Text(article.title)
}
// ⚠️ Only safe if titles are unique — id should always be truly unique

Key Points:

  • id can be any Hashable type — UUID, Int, String
  • Using a non-unique id causes incorrect animations and potential crashes
  • UUID() is the safest default for new models