一个小例子看懂swift中可选绑定

13. October 2015 Swift 0

可选绑定用于判断可选类型变量是否有值,可用于if分支或者while循环中

var str:String? = “lijian”

if var m = str{

print(m)

}

else{

print(“str 为 nil”)

}


Leave a Reply

Your email address will not be published. Required fields are marked *