深入探索表格视图与Cocoa绑定技术
1. 表格视图的基本使用
在开发中,我们常常需要在表格视图中展示和操作数据。当表格视图需要显示单元格时,会调用特定的方法。例如,根据列名来创建并配置相应的视图:
} else if ([thisColName isEqualToString:kLastSeenDate]) {
NSTableCellView *thisCell = [aTableView makeViewWithIdentifier:thisColName owner:self];
thisCell.textField.stringValue = [thisVillain objectForKey:kLastSeenDate];
result = thisCell;
} else if ([thisColName isEqualToString:kMugshot]) {
NSImageView *thisCell = [aTableView makeViewWithIdentifier:thisColName owner:self];
[thisCell setImage:[thisVillain objectForKey:kMugshot]];
result = thisCell;
}
// return the result.
return result;
这个方法根据列名创建对应的视图,并从模型对象中获取数据填充视图,最后返回该视图供表格视图绘制。
当我们编译并运行应用时,默认的反派角色会显示在控件和表格视图中。如果在控件中编辑
超级会员免费看
订阅专栏 解锁全文
10

被折叠的 条评论
为什么被折叠?



