Convert a string into an int

后端 未结 11 2454
别跟我提以往
别跟我提以往 2020-12-04 14:51

I\'m having trouble converting a string into an integer. I googled it but all I can find is how to convert an int into a string. Does anyone know how to do it the other way

11条回答
  •  自闭症患者
    2020-12-04 15:29

    To convert an String number to an Int, you should do this:

    let stringNumber = "5"
    let number = Int(stringNumber)
    

提交回复
热议问题