this class is not key value coding-compliant for the key xx

来源:互联网 发布:永琪和知画圆房视频 编辑:程序博客网 时间:2024/06/05 17:27

这种情况有5种:

1,加载自定义的tableViewCell的时候总是死在:

        XInstrumentOpenCell *cell = [tableViewdequeueReusableCellWithIdentifier:CellTableIdentifier];


log里面报错:this class is not key value coding-compliant for the key closeLotTextField


解决方法:

因为xib的属性检查器中,没有设置Identifier为cellID

    static NSString *CellTableIdentifier = @"cellID";

2,在加载WorkingOrder界面的时候,总是报这个错误:

解决方法:

因为在xib的连接中,有一个变量stateLabel是已经删除了的(用phaseLabel代替了)。虽然代码已经删除了,但是连线还是存在于xib文件中。

删掉这个多余的连接线就好了。


3,检查代码拼写,有时候改了类的名字,但是有些地方没有改过来,就会一直报这种错误,比如

NSArray *secondLevelObjects = [[NSBundlemainBundleloadNibNamed:@"XOpenPositionContentCell"owner:niloptions:nil];

重点是字串中的类名,一般使用类名定义的时候很好找出来改掉,但是写在字串里面的不容易被发现


4,连线的时候选择的是cell 不是file‘s owner,有时候设置了xib文件的class,但是项目未更新过来,重启xcode。


注意:前四种情况我没有遇到过,看的别人给的,具体行不行我就不知道了。


5,

    NSDictionary* dicID = [NSDictionarydictionary];

    [dicID setValue:_myCollectionViewIDforKey:@"myCollectionViewID"];

    [dicID setValue:[NSNumbernumberWithInteger:_cyModel.modle_s_Id]forKey:@"dbID"];

    [dicID setValue:[NSNumbernumberWithInteger:_dataArrayID]forKey:@"dataArrayID"];

    [[NSNotificationCenterdefaultCenter] postNotificationName:@"DELTEL"object:niluserInfo:dicID];


就是这个KEY值有问题,最好的解决方案就是不要用字典,在object上用数组。
0 0
原创粉丝点击