Is there a way to pass a float from one variable to another variable of type string? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Is there a way to pass a float from one variable to another variable of type string?

I need to display some values in an iPhone app. These values have looong names and I have to make them part of a text to be placed in aa text field. How?

29th Sep 2018, 7:56 AM
Gladys
5 Answers
+ 3
typecasting perhaps?
29th Sep 2018, 10:10 AM
Jonathan Pizarra (JS Challenger)
Jonathan Pizarra (JS Challenger) - avatar
+ 1
Unfortunately, I'm not familiar with Swift syntax. But I hope this helps https://medium.com/@abhimuralidharan/typecastinginswift-1bafacd39c99
29th Sep 2018, 12:16 PM
Jonathan Pizarra (JS Challenger)
Jonathan Pizarra (JS Challenger) - avatar
+ 1
Idk swift either, but I saw somewhere that you can do: text = String(format: "a float number: %.5f", 1.0321); I don't have where to test it though.
29th Sep 2018, 12:27 PM
lion
lion - avatar
0
Exactly so how is typecasting done in Swift?
29th Sep 2018, 12:10 PM
Gladys
0
Thanks will try that
29th Sep 2018, 12:24 PM
Gladys