How to create a string with format?

后端 未结 12 1334
别跟我提以往
别跟我提以往 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:07

    Use this following code:

        let intVal=56
        let floatval:Double=56.897898
        let doubleValue=89.0
        let explicitDaouble:Double=89.56
        let stringValue:"Hello"
    
        let stringValue="String:\(stringValue) Integer:\(intVal) Float:\(floatval) Double:\(doubleValue) ExplicitDouble:\(explicitDaouble) "
    

提交回复
热议问题