twostraws / ControlRoom

A macOS app to control the Xcode Simulator.
MIT License
5.77k stars 304 forks source link

Use NumberFormatter for SliderFieldView Text. #73

Closed CypherPoet closed 4 years ago

CypherPoet commented 4 years ago

Fixes https://github.com/twostraws/ControlRoom/issues/72

See explanation here

twostraws commented 4 years ago

It looks like the previous commit might have used Xcode 11.4, which compiles the code cleanly. I wonder whether in this instance using Text("\(value, specifier: "%.2f")") would be an easier change? It should compile just fine on Xcode 11.3. Thoughts?

CypherPoet commented 4 years ago

Ah, that does compile successfully, too.

Another advantage of NumberFormatter is that the string is automatically localized (wrt the decimal symbol, for example), but I could go with the specifier solution if you think the extra overhead isn't worth it.

twostraws commented 4 years ago

That's a great reason to go with your solution – thank you!