-
-
Save onato/9d12bbbf5c4135673f24 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "OResultOutlineViewController.h" | |
@implementation OResultOutlineViewController | |
- (id)init | |
{ | |
self = [super init]; | |
if (self) { | |
_data = @[@"0",@"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9",@"10",@"11",@"12",@"13",@"14"]; | |
} | |
return self; | |
} | |
#pragma mark - NSOutlineViewDelegate | |
- (NSInteger)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item | |
{ | |
if (!item) { | |
item = self.data; | |
} | |
NSUInteger returnValue = 0; | |
if ([item isKindOfClass:[NSArray class]]) { | |
returnValue = [item count]; | |
} | |
return returnValue; | |
} | |
- (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item | |
{ | |
id value = item; | |
if (![value isKindOfClass:[NSArray class]] && ![value isKindOfClass:[NSDictionary class]]) { | |
return NO; | |
} | |
return [value count]; | |
} | |
- (id)outlineView:(NSOutlineView *)outlineView child:(NSInteger)index ofItem:(id)item | |
{ | |
if (!item) { | |
item = self.data; | |
} | |
id returnValue = @""; | |
if ([item isKindOfClass:[NSArray class]]) { | |
returnValue = @"value";//[item objectAtIndex:index]; | |
} | |
// return @{@"index":@(index), @"value":returnValue}; // produces EXC_BAD_ACCESS in outlineView:objectValueForTableColumn:byItem: | |
return returnValue; | |
} | |
- (id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item | |
{ | |
if ([tableColumn.identifier isEqualToString:@"keyColumn"]) { | |
return @"key"; | |
} | |
if ([tableColumn.identifier isEqualToString:@"valueColumn"]) { | |
return @"value"; | |
} | |
return @"type"; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment