This seems like really basic functionality, but I'm pulling my hair out trying to find a good example in Swift.
Problem: Everything that I've read, and seen examples in Objective-C, you set the state of the checkboxes in the "objectValueFor" datasource method by returning a 1 for state on, and 0 for state off, but it's not working.
func tableView(_ tableView: NSTableView,
objectValueFor tableColumn: NSTableColumn?,
row: Int) -> Any? {
if (tasks == nil) || (tableColumn == nil) {
return 0
}
let taskName = tasks!.tasks[row].name
for assignedTask in assignedTasks! {
if (assignedTask == taskName) {
return 1
}
}
return 0
}
If I set the state of the checkbox in the XIB to on, all of them are turned on, regardless of the if statement, and if I set the state in the XIB to off, they're all turned off, again regardless of the if statement, meaning that, although this function is being called, its return value is being ignored.
Thanks for any help! Just a pointer to a good example of a checkbox in a NSButtonCell, written in Swift, would be well appreciated -- the one I found on Apple's website (the "iSpend" project) is so old it can't be opened by Xcode 12.