I would like to create an NSTableview with custom NSTableCellViews.
Here is what I have right now:
- The nib file for the cell (view nib) called CustomCell.xib
- A custom class for my cell called CustomCell
- And the code in my AppDelegate.m :
Here I programmatically create my table view:
NSScrollView *tableContainer = [[NSScrollView alloc]initWithFrame:NSMakeRect(self.window.frame.size.width-TABLEWIDTH, 0, TABLEWIDTH, self.window.frame.size.height)]; NSTableView *tableView = [[NSTableView alloc] initWithFrame:NSMakeRect(self.window.frame.size.width-TABLEWIDTH, 0, TABLEWIDTH, self.window.frame.size.height)]; NSTableColumn *firstColumn = [[[NSTableColumn alloc] initWithIdentifier:@"firstColumn"] autorelease]; [[firstColumn headerCell] setStringValue:@"First Column"]; [tableView addTableColumn:firstColumn]; tableView.dataSource = self; tableView.delegate = self; [tableContainer setDocumentView:tableView]; tableContainer.autoresizingMask = NSViewHeightSizable | NSViewMinXMargin; [self.window.contentView addSubview: tableContainer];
And here is the delegate method, where I would like to put my own cell code:
- (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
In the nib file for my custom cell, I connected the cell view using my customCellCell class, which subclasses NSTableCellView . I haven’t done anything yet. So my CustomCell.m is just the default initialization code. I did not touch him. And I didn’t do anything in my nib file, so I did not change the owner of the file or anything like that, because I really do not know what to do. Can anyone help? I looked at sample files from the Apple documentation, but after several days of research, I did not find any solutions. I would really appreciate it if you could help me.
source share