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
Asked
Active
Viewed 102 times
1 Answers
1
you can just replace your code wherever you use the bool to
yourBoolValue ? 2 : 0

Chris
- 7,579
- 3
- 18
- 38
-
How would I store this value because when I try and assign the output of the Toggle to an old variable it says: Binding
is not convertible to – EliasFiz May 10 '20 at 14:00 -
please show me your code than i can help you....best would be if it is runnable and compilable. normally _yourvariable = true should work – Chris May 10 '20 at 14:46
-
Thank you so much, I opened another question with my code at https://stackoverflow.com/questions/61714040/when-i-try-and-assign-the-output-of-the-toggle-to-an-old-variable-it-says-bindi – EliasFiz May 10 '20 at 14:59