How to create a string with format?

后端 未结 12 1337
别跟我提以往
别跟我提以往 2020-11-30 18:13

I need to create a string with format which can convert int, long, double etc. types into string. Using Obj-C, I can do it via below way.

NSString *str = [NS         


        
12条回答
  •  执念已碎
    2020-11-30 19:09

    No NSString required!

    String(format: "Value: %3.2f\tResult: %3.2f", arguments: [2.7, 99.8])
    

    or

    String(format:"Value: %3.2f\tResult: %3.2f", 2.7, 99.8)
    

提交回复
热议问题