ios - unexpectedly found nil while unwrapping an Optional value
迷茫
迷茫 2017-04-17 14:53:01
0
1
514

调试时遇到的问题错误,求解决办法

迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

reply all(1)
洪涛

Looking at this error description, the questioner probably forcibly unpacked the optional variables, right? Forced unpacking must ensure that the variable value is not empty, otherwise an error will be reported. The insurance method is as follows:

var a:Int?
if let a1 = a {
    //如果a非空,就会将a的值赋值给a1,然后直接用a1就行了
}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template