struct LabelAnnotations: Codable {
let description: String
let score: Double
}
and you want it to map to array of
struct ImageProperties: Identifiable {
let id: UUID
let description: String
let score: String
}
Do you really need UUID? Maybe LabelAnnotations have unique description field? In which case you may use description as id:
struct LabelAnnotations: Codable, Identifiable {
var id: String { description }
let description: String
let score: Double
}
Or, if description is not unique, and neither is the combination of description + score, maybe array index can act as an identifier for you?
struct LabelAnnotations: Codable, Identifiable {
let id: Int // 0, 1, 2, ...
let description: String
let score: Double
}
Or maybe you don't need identifiable at all, just Hashable?
struct LabelAnnotations: Codable, Hashable {
let description: String
let score: Double
}
// needs identifiable items
// ForEach(items) { item in
// }
// ok with hashable items
ForEach(items, id: \.self) { item in
}
Or, perhaps there was some other identifier in your source material (where are you getting LabelAnnotations from?), and it's just a matter of propagating it? This is the best approach.