I have a Mac OS X application that uses NSOutlineView with two columns: a key and a value, where you can edit a column of values. I either have an NSString or an NSDictionary in a string. The code for the cell values is as follows:
- (id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item {
if ([[[tableColumn headerCell] stringValue] isEqualToString:@"Key"]) {
id parentItem = [outlineView parentForItem:item] ? [outlineView parentForItem:item] : root;
return [[parentItem allKeysForObject:item] objectAtIndex:0];
} else {
if ([item isKindOfClass:[NSString class]]) {
return item;
} else if ([item isKindOfClass:[NSDictionary class]]) {
return @"";
} else {
return nil;
}
}
}
It works as it should, except when the field value has the same string value. It always just takes the first element with this value to show it as a key, so the same key value will appear for all value values that are the same. Does anyone know how to fix this problem?
Ulrik damm
source
share