View-based NSOutlineView performs badly
Hi dear community,
I'm currently trying to use a view-based NSOutlineView in my application and everything looks good so far. However, I experience some weird performance issues when using more than one view. I implemented the following method, to provide two views (the default dataCell and headerCell ones, IB creates for a new outline view depening on the kind of item)
- (NSView *)outlineView
NSOutlineView *)outlineView
viewForTableColumn:(NSTableColumn *)tableColumn
item:(id)item {
NSTableCellView *result = nil;
if ([item isKindOfClass:[NSMutableDictionary class]]) {
result = [outlineView makeViewWithIdentifier:@"HeaderCell" owner:self];
id parentObject = [outlineView parentForItem:item] ? [outlineView parentForItem:item] : groupedRoster;
[[result textField] setStringValue:[[parentObject allKeys] objectAtIndex:0]];
} else {
result = [outlineView makeViewWithIdentifier:@"DataCell" owner:self];
[item nickname] ? [[result textField] setStringValue:[item nickname]] : [[result textField] setStringValue:[[item jid] bare]];
}
return result;
}
When I just call
makeViewWithIdentifier with a single identifier (e.g. just the HeaderCell or just the DataCell)
the performance is great, just like in finder. However, when using both like above, expanding and collapsing gets
quite slow and laggy while CPU usage spikes. Could anyone explain why that is?
Mac OS X (10.7)