[SwiftUI] List(list, id: \.self)에서 "id:"를 생략하고 싶을 때


[SwiftUI] List(list, id: \.self)에서 "id:"를 생략하고 싶을 때

// 기존 형태 List(list, id: \.self) { item in StockRankRow(stock: item) .listRowInsets(EdgeInsets(top: 0, leading: 0, bottom: 0, trailing: 0)) .listRowSeparator(.hidden) .frame(height: 80) } .listStyle(.plain) .background(.black) // 가져오는 데이터 struct StockModel: Hashable { let rank: Int let imageName: String let name: String let price: Int let diff: Double } 대충 이런 형식이다. List(list, id: \.self) 에서 id:는 구분자를 설정하기 위해서인데 그것을 데이터 쪽에서 설정할 수 있다. struct StockModel: Hashable, Identifiable { var id: UUID = UUID(...


#id #Identifiable #List #swiftui #uuid

원문링크 : [SwiftUI] List(list, id: \.self)에서 "id:"를 생략하고 싶을 때