I have a Mac OS X application that uses an NSOutlineView with two columns: key and value, where you can edit the value column. I either have a NSString or a NSDictionary in a row. The code for the value of the cells is like this:
- (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's working as it should, except for when to value fields has the same string value. It always just takes the first element with that value to show as the key, so the same key value will appear for all value values that are the same. Anybody know how to fix this problem?