objective-c - 自定义 UITableViewCell NSUnknownKeyException

标签 objective-c ios uitableview

- (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;
 }

运行时:

 NSArray *nib=[[NSBundle mainBundle] loadNibNamed:@"TodoTableViewCellController" owner:self options:nil];

但有一个异常(exception): * 由于未捕获的异常“NSUnknownKeyException”而终止应用程序,原因:“[setValue:forUndefinedKey:]:此类在关键日期不符合键值编码。”

我不知道为什么会这样,所以请帮我解决这个问题,在此先感谢您!

最佳答案

该错误意味着您已将某些东西连接到 Nib 中名为 date 的 socket ,但该 socket 不存在。你在哪里声明日期?

关于objective-c - 自定义 UITableViewCell NSUnknownKeyException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9852441/

相关文章:

objective-c - 如何在 Mac OS X 上将 CALayer 添加到 NSView

ios - 如何在每个 View Controller 中正确管理 NSManagedObjectContext?

objective-c - 编译 iPad 应用程序时出现奇怪的错误(ld : duplicate symbol _OBJC_CLASS_$)

ios - UITableViewController 不会在自定义实现上滚动

xcode - 如何在 UITableViewCell 中添加多行

c++ - 将静态 C++ 库包含到 Objective C 项目中

ios - 通过 iTunes(或其他?)访问 iOS 应用程序中的 .plist 文件

objective-c - 标签栏项目的标题不显示

ios - SwiftUI 2 生命周期 - 处理自定义 URL 方案

ios - UITableView beginUpdate/endUpdate 导致滚动到顶部