Get integer value from string in swift

后端 未结 12 1826
小蘑菇
小蘑菇 2020-11-27 17:14

So I can do this:

var stringNumb: NSString = \"1357\"

var someNumb: CInt = stringNumb.intValue

But I can\'t find the way to do it w/ a

12条回答
  •  無奈伤痛
    2020-11-27 17:54

    You can bridge from String to NSString and convert from CInt to Int like this:

    var myint: Int = Int(stringNumb.bridgeToObjectiveC().intValue)
    

提交回复
热议问题