I have class as shown below:
struct Cur: Decodable {
let id: String
let name: String
let symbol: String
let switchVal:Bool
}
This class populates an array and the array is being displayed in UITableView. How to detect which switch button (switchVal) is toggled, therefore how to get "id" of the related element.
I am detecting when UISwitchButton is toggled inside a prototype cell like this:
@IBAction func switchBtn(_ sender: UISwitch) {
if sender.isOn {
}
}
== trueis redundant. To check if not isOn just useif !sender.isOn