After changing the cell-based NSOutlineView based on the view, it does not display the icons and headers of the file system tree. Here is my code:
- (void)outlineView:(NSOutlineView *)outlineView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item {
if ([[tableColumn identifier] isEqualToString:@"name"])
return [(ImageAndTextCell *)cell setTextFieldImage:[item icon]];
}
- (id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item {
return [((ConstructorFSEntity *)item) title];
}
- (NSView *)outlineView:(NSOutlineView *)outlineView viewForTableColumn:(NSTableColumn *)tableColumn item:(id)item {
if ([item isKindOfClass:[FSEntity class]]) {
return [outlineView makeViewWithIdentifier:@"HeaderCell" owner:self];
} else {
return [outlineView makeViewWithIdentifier:@"DataCell" owner:self];
}
}
And I have one more question. How to put enumerated elements (an array of a file system element) in the "DataCell" cell, and declare "HeaderCell" to be the parent folder (group) and assign it a title (for example, @ "Root folder") and the class path. Since now the previous view-based method only displays the enumerated item in “HeaderCell” or “DataCell”, and when I try to assign a value to “HeaderCell”, the application crashes. Can you help me?