自定义UITableViewCell NSUnknownKeyException

jxd*_*ter 6 objective-c uitableview ios

- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *TodoListTableIdentifier = @"TodoListTableIdentifier";
    TodoTableViewCellController *cell = (TodoTableViewCellController *)[tableView dequeueReusableCellWithIdentifier:TodoListTableIdentifier];
    if ( cell == nil ) 
    {
        NSArray *nib=[[NSBundle mainBundle] loadNibNamed:@"TodoTableViewCellController" owner:self options:nil];
        cell=[nib objectAtIndex:0];
        [cell setSelectionStyle:UITableViewCellSelectionStyleGray];  
    }
    Todo *todo = [self.allTodoArray objectAtIndex:[indexPath row]];


    cell.titleLabel.text = todo.fileTitle;
    cell.money.text = [NSString stringWithFormat:@"Monei:%f",todo.amount];
    cell.name.text = todo.realName;
    cell.date.text = todo.operateTime;

    return cell;
 }
Run Code Online (Sandbox Code Playgroud)

在跑步时:

 NSArray *nib=[[NSBundle mainBundle] loadNibNamed:@"TodoTableViewCellController" owner:self options:nil];
Run Code Online (Sandbox Code Playgroud)

并且有一个例外: *由于未捕获的异常'NSUnknownKeyException'而终止应用程序,原因:'[setValue:forUndefinedKey:]:此类不是关键日期的密钥值编码兼容.

我不知道为什么会发生,所以请帮助我,提前谢谢你!

bor*_*den 16

该错误意味着您已将某些内容连接到笔尖中名为date的插座,但该插座不存在.你在哪里申报日期?

  • 好的,我犯了一个错误:dateLabel连接到文件的所有者,它应该连接到CellController!谢谢 ! (3认同)