I am creating a series of ImageCheckRows as a SelectableSection, and I would like to set some default values. Essentially each row returns a true/false value, so somewhere there should be a simply method of setting true or false on each row. I tried the row.value but this requires a 'String?'
currentSection! <<< ImageCheckRow<String> { row in
row.tag = "\(tagname)_\(optionKey)"
row.title = optionValue as? String
row.selectableValue = optionKey as? String
if let dvkey = optionKey as? String {
print("dvkey = \(dvkey)")
if let _ = defaultValues?.value(forKey: dvkey) {
print("we found dvkey in the defaultValues dict - try row.select")
row.value = true
}
}
}.cellSetup { cell, _ in
cell.trueImage = UIImage(named: imageChecked)!
cell.falseImage = UIImage(named: imageUnchecked)!
}
I also tried using the function:
row.select()
But this didn't work either.
Then I tried moving it to the cellSetup, but this didn't work either.
Can anyone help me here?
Worked it out myself...
row.value = optionKeyValue as? String
This is a radio button style control, and as I create the row with the default radio button I set the value to the key, however it must be a string representation, even if it is numeric. Who would have guessed!
My first thought was that the radio button control is checked/unchecked, hence it should really be a true/false value.
My second thought was that the radio button control default value would be set against the group, which is a more logical place to set or change the value.
Wrong on both counts.