UITableViewCell error - this class is not key value coding-compliant for the key [duplicate]

偶尔善良 提交于 2019-12-03 07:27:35

Make sure that File's Owner in the nib is set to NSObject and also make sure that there are no outlets wired up to File's Owner.

Check all of the elements in your nib to be sure their not referencing something that no longer exists. Right click on them to see what is pointing at what. There will be something in there for sure.

Looks like you have linked a UILabel in your nib with an IBOutlet that is not existing anymore in your code (descriptionLabel).

So check your nib file again. I had this error several times too and this was the solution for me.

I had exactly the same error and was wondering why my IBOutlets from the .h file weren't showing when I right-clicked the Table Cell in "Objects" on the left, but only at File's Owner. I found out that when I left clicked on my custom table cell in the "view" of the xib file and then in the attributes inspector assigned it to the correct custom (tableViewCell) class at "identifier", the outlets showed up at Table Cell at "Objects". Maybe this helps!

In my case problem was solved by checking presence of .m in list of compilable sources.

If you rename, move or add new sources for custom table cell (or anything else needed by Interface Builder) you should add them to Project -> Targets -> -> Build Phases -> Compile Sources.

If you have more than one target - check all targets. In my project there was active target with type of Aggregate (with custom IPA building script), and i think this the root of problem because newly added *.m files misses Compile Sources list for Application-type target.

Sameer
static NSString *CellIdentifier = @"CellIdentifierName";
ContentPackCell *cell = (ContentPackCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];

if (cell == nil) {
    [[NSBundle mainBundle] loadNibNamed:@"ContentPackCell" owner:self options:nil] ;
    cell=objCustomCell;
}

Have you tried like this,

ContentPackCell *cell = (ContentPackCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
  [self.cellNib instantiateWithOwner:nil options:nil]; //Make owner nil
  cell = tmpCell;
  self.tmpCell = nil;
}

Usually when you do [[NSBundle mainBundle] loadNibNamed:@"ContentPackCell" owner:nil options:nil]; you get errors like what you get now. So if you getting error like "this class is not key value coding-compliant", in both the cases the reason is Class is not set for "File Owner" of Custom cell.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!