关于unrecognized selector sent to instanc

来源:互联网 发布:nokia5300软件下载 编辑:程序博客网 时间:2024/05/19 19:13

今天遇到个问题颇是拖延了点时间,错误报错如下:


[UIAccessibilityBundle setStrName:]: unrecognized selector sent to instance 0x6891180

错误指向语句是一个strName的赋值语句


这个错误之所以费了时间,原因在于我定位错误的时候错误的将该错误定位为方法或者属性未定义,但是我看上面定义的类型里明明却是是写过了这个属性,为什么会无法执行呢?

顺次向上推敲代码,找到这样一行代码


CustomCell *cell = [tableView dequeueReusableCellWithIdentifier:@"CustomCellIdentifier"];

也就是寻找identifier被设置为了CustomCellIdentifier的object

查看dequeueReusableCellWithIdentifier方法的说明,在Return Value里的说明为

A UITableViewCellobject with the associated identifier or nil if no such object exists in the reusable-cell queue.


换句话说,它只是找到并且返回同样的identifier的队列成员中的一个!

反复整个工程查找定位CustomCellIdentifier,发现有两个table view cell的identifier都被定义为了CustomCellIdentifier,但是系统未给出过警告或者相关信息,由此返回了另一个identifier值导致找到了错误的结果


尚未找到确切的方法检测应用是否有相同的identifier存在,所以这里只能多加细心,待以后找到了方法之后再来补充


原创粉丝点击