Hello I am trying to connect a method from a class into a view but it is popping up with type '()' cannot conform to 'view'. The error is at the call to the showcard method in the scroll view. The second block of code is the class I am calling it from and the method I am using. Thank you
VStack{
headerView
ScrollView(.horizontal, showsIndicators: false){
HStack(spacing: 10){
viewModel.showCard()
}
}
Spacer()
}
}
@MainActor class ViewModel: ObservableObject{
@EnvironmentObject var wallet: Wallet
func showCard() {
ForEach(wallet.cards.indices, id:\
.self) { index in
CardView(card:
self.wallet.cards[index])
.onTapGesture {
self.wallet.cards.indices.forEach{ index in
self.wallet.cards[index].isSelected = false
}
self.wallet.cards[index].isSelected.toggle()
}
}
}
}
}