//代码创建NSTableView
-(void)CreateNSTableViewUI{
NSTableView * tableView = [[NSTableView alloc] initWithFrame:self.view.bounds];
[self.view addSubview:tableView];
//这里可以建立数据源加载
for (int i=0; i<5; i++) {
NSTableColumn * Column=[[NSTableColumn alloc] initWithIdentifier:[NSString stringWithFormat:@"Col%02d",i]];
[Column setTitle:[NSString stringWithFormat:@"Test"]];
[Column setHeaderToolTip:[NSString stringWithFormat:@"Name"]];
NSNumber * width = @(100);
Column.width=[width floatValue];
Column.editable=NO;
NSTextFieldCell * cell = [[NSTextFieldCell alloc] init];
[Column setDataCell:cell];
[tableView addTableColumn:Column];
}
[tableView reloadData];
NSScrollView * scrollView = [[NSScrollView alloc] initWithFrame:self.view.bounds];
[self.view addSubview:scrollView];
scrollView.contentView.documentView = tableView;
}