I have a Core Data NSManagedObject entity Person with a Bool attribute that I generate as a NSNumber. (the "Use Scalar Type" checkbox is not used, so the Bool attribute becomes an NSNumber)
I am trying to observe this attribute, employed, to control the UI.
@ObservedObject var person: Person
var body: some View {
List {
Section {
HStack {
Toggle(isOn: $person.employed) { <-- 1
Text("Showing employed content..")
}
}
}
if person.employed.boolValue {
Section { } etc
I get a warning at "1" saying: Cannot convert value of type 'Binding<NSNumber?>' to expected argument type 'Binding<Bool>'
How can I make use of the employed attribute as a bool without changing it to a scalar?
Note: $person.employed.boolValue would not work it seems, and I would also have to account for the optional part.