Tag based selected button multiple checkbox in cell iOS swift
Problem:
I'm having cell with checkbox buttons options.I'm getting data values from api with name and tag value as id.I want to show selected the button if id is selected in the api list.
I'm getting the selected list as string with , appended.
How to achieve that?
Solution:
if let detail = mydetails {
if let values = detail. values?.split(separator: ",") {
for val in values {
let id = Int(val)
if let btn = cell.viewWithTag(id ?? 0) as? UIButton {
btn.isSelected = true
}
}
}
}
Comments
Post a Comment