attempt to insert nil object from objects[0]

attempt to insert nil object from objects

试图从对象插入零对象

attempt to insert nil object from objects[0]_第1张图片
该错误出现的原因为对nil属性进行了操作

原因如下:

self.tagList.selectedArray.count <= 0

self.tagList.selectedArray数据源为nil

对nil进行了.count运算

解决问题心得:

解决该问题先找出出错的数组,该数组存在的含义,在哪儿用到,数组里面存放的什么东西。

debug调试是否为nil,为nil对数组做判断

解决方法:

if(self.tagList.selectedArray && self.tagList.selectedArray.count <= 0 )

1.  self.tagList.selectedArray先确定self.tagList.selectedArray不为nil

2.  再对self.tagList.selectedArray进行.count操作

你可能感兴趣的:(attempt to insert nil object from objects[0])