Lumialxk Lumialxk -5 years ago 169
iOS Question

How to add percent sign in string format?

I want to get string like

,and I used format to get this:

let rate = 99.99999
let str = String(format: "%.2f%", rate)
// output 99.99

is not allowed. So how to add percent sign in string format, please help me!

Answer Source

write two time %:

rate = 99.99
let str = String(format: "%.2f%%", rate)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download