Hi, I'm new to SwiftUI and have been trying to accomplish this without success.
I have the following arrays and need to filter out from the options array the items that exist in the selected array.
import SwiftUI
struct Option: Decodable, Hashable {
var userCode: String
var optType: String
var optValue: String
}
struct Selected: Decodable, Hashable {
var userCode: String
var tradeCode: String
var optType: String
var optValue: String
}
struct ContentView: View {
@State var options = [
Option(userCode: "1", optType: "Emotions", optValue: "Sad"),
Option(userCode: "1", optType: "Emotions", optValue: "Happy"),
Option(userCode: "1", optType: "Emotions", optValue: "Angry"),
Option(userCode: "1", optType: "Emotions", optValue: "Calm")
]
@State var selected = [
Selected(userCode: "1", tradeCode: "1", optType: "Emotions", optValue: "Sad"),
Selected(userCode: "1", tradeCode: "1", optType: "Emotions", optValue: "Happy")
]
var body: some View {
Button("Options Not Selected") {
//Here I need an array of the options NOT selected
}
}
}
Any help would be greatly appreciated.
Thanks
Selecting any option will automatically load the page