import SwiftUI
class aViewModel: ObservableObject {
@Published var abc: Set<(aa:String,bb:String,cc:Double,dd:Int)> = [] // Type '(aa: String, bb: String, cc: Double, dd: Int)' does not conform to protocol 'Hashable'
func fetchData() async throws {
// Url Stuff
}
}
struct ContentView: View {
@StateObject var ViewModel = aViewModel()
var body: some View {
...
.task {
do {
try await ViewModel.fetchData()
} catch {
// Show Alert
}
}
ForEach($ViewModel.abc,id: \.self) { e in
//Using for stuff..
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
I tried not putting <(aa:String,bb:String,cc:Double,dd:Int)>
but this causes to be any set. Because any is not Hashable
it causes error. I can't even change to array because set fixes an bug. If i try to solve the bug with array it causes big performance drops. What do I need to do in this situation?