问答详情
源自:2-5 Swift-可选型 Optionals

var age = userInput.toInt() 现在不支持啦?编译器报错,xcode7

var age = userInput.toInt() 现在不支持啦?编译器报错,xcode7

提问者:JohnHuang 2015-09-19 22:58

个回答

  • weixin_慕圣4150750
    2017-06-25 15:16:51

    let userInput = "abc"
    var userage = Int(userInput)!


  • 精慕门4127614
    2016-04-05 20:16:36

    同问,上面两答都没反应.....

  • SaintW
    2015-12-24 22:01:48

    let  inputs = "19"

    var _age = Int(inputs)

    if _age != nil

    {

        print("Your age is \(_age!)")

    }

    else

    {

    print("Invid age")    

    }


  • Joshua007
    2015-10-30 14:09:25

    已经取消了,直接用强制类型转换Int(userInput)。

  • will1989
    2015-10-14 21:27:38

    老师能给个最新的开发文档吗

  • Cooper_H
    2015-10-03 23:39:36

    同问。。。