I currently have a line of code which creates random numbers 1-5, but how do I include decimals, 1.00-5.00?
stoptimer.text = String(arc4random_uniform(4)+1)
I currently have a line of code which creates random numbers 1-5, but how do I include decimals, 1.00-5.00?
stoptimer.text = String(arc4random_uniform(4)+1)
You can convert your Int to Double and use String(format:) method to format your string as desired:
stoptimer.text = String(format: "%.2f", Double(arc4random_uniform(5)+1))
Increase the range of your generated numbers from 100 to 500 and devide the resulting one by 100.
stoptimer.text = String((arc4random_uniform(400)+100) / 100)