Converting String to Int with Swift

前端 未结 30 1291
小鲜肉
小鲜肉 2020-11-22 06:59

The application basically calculates acceleration by inputting Initial and final velocity and time and then use a formula to calculate acceleration. However, since the value

30条回答
  •  鱼传尺愫
    2020-11-22 07:11

    In Swift 4.2 and Xcode 10.1

    let string:String = "789"
    let intValue:Int = Int(string)!
    print(intValue)
    
    let integerValue:Int = 789
    let stringValue:String = String(integerValue)
        //OR
    //let stringValue:String = "\(integerValue)"
    print(stringValue)
    

提交回复
热议问题