Search code examples
cosmicmind

Can I change MaterialSwitch to true/false instead of on/off?


Anyway I can change MaterialSwitch to return true/false instead of on/off?

print(switch.switchState) // prints true

Solution

  • Hearing nothing else, I improvised and created a new bool variable. Then I just used if statements to set it correctly by accessing the hashValue.

     if self.option1.switchState.hashValue == 1 {
            option1Value = false
        } else {
            option1Value = true
        }