Search code examples
swiftswiftuitoggleswift-playground

Change output of a SwiftUI Toggle


Is there a way to change the output of a SwiftUI Toggle. The default values are True and False but can I change to a pair of numbers e.g. 2 and 0


Solution

  • you can just replace your code wherever you use the bool to

     yourBoolValue ? 2 : 0