Reputation: 2977
I'm trying to nest one NSTableView inside another view based tableview in my xib. When I do so, I get the following build error (when trying to compile the xib):
An instance of NSTableColumn with object ID jRp-dg-jOe did not archive its child (NSTableCellView) with an object of ID y8a-qz-ChK
Has anybody seen this, or know how to fix it?
I assume I could just create another xib for the NSTableCellView, and hook it up to the parent NSTableView using
NSNib *cellNib = [[NSNib alloc] initWithNibNamed:@"MyCellContainingAnNSTableView" bundle:nil];
[parentTable registerNib:cellNib forIdentifier:@"SomeIdentifier"];
but that's a little more annoying...
Upvotes: 3
Views: 1037
Reputation: 2977
OK so it seems like nobody has any solutions for this...
After a long time looking, it seems that Interface Builder is just incapable of archiving nested NSTableViews. My solution was to create a new .xib
containing an NSTableCellView
and referencing that from the original NSTableView
. Here's how to do it:
.xib
. Call it something like SchemeCell.xib
NSTableViewDelegate
to your code, and set it as the delegate for your main (parent) tableview.Add in the method:
- (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
NSNib *cellNib = [[NSNib alloc] initWithNibNamed:@"SchemeCell" bundle:nil];
[self.schemeTableView registerNib:cellNib forIdentifier:@"SchemeCell"];
});
return [self.schemeTableView makeViewWithIdentifier:@"SchemeCell" owner:self];
}
And away you go! Now the main disadvantage to this is that you can no longer use Interface Builder to hook up items from the SchemeCell
to the parent NSTableView
(since they are now both in separate .xibs
, but it's not the end of the world, because you can do all of this within the code of course.
Upvotes: 7