一位大牛写的 Dictionary+NilSafe 防止字典中的数据为nil导致的崩溃,在项目中非常有用,以后在项目中应该用得着。
github.com地址: https://github.com/allenhsu/NSDictionary-NilSafe
一、在未使用的情况下
代码亲测:
![](https://img.haomeiwen.com/i1249524/afce432063e1cf3a.png)
打印输出:
![](https://img.haomeiwen.com/i1249524/0b755b5b0e0a42c8.png)
二、亲测使用Dictionary+NilSafe
代码亲测:
![](https://img.haomeiwen.com/i1249524/e8476a554d9f2b92.png)
使用Dictionary+NilSafe传值nil无崩溃,打印输出里面字典会去除@“wang”,如下图所示:
![](https://img.haomeiwen.com/i1249524/d8a7676549384678.png)
一位大牛写的 Dictionary+NilSafe 防止字典中的数据为nil导致的崩溃,在项目中非常有用,以后在项目中应该用得着。
github.com地址: https://github.com/allenhsu/NSDictionary-NilSafe
一、在未使用的情况下
代码亲测:
打印输出:
二、亲测使用Dictionary+NilSafe
代码亲测:
使用Dictionary+NilSafe传值nil无崩溃,打印输出里面字典会去除@“wang”,如下图所示:
本文标题:iOS防止字典中的值为nil导致的崩溃
本文链接:https://www.haomeiwen.com/subject/enfeoxtx.html
网友评论