Extension of all NSOutlineView elements that load data from a data source

First of all, I'm new to cocoa development, so I suppose I'm probably trying to get it wrong, but here goes:

I have NSOutlineViewone that loads data from an implementation NSOutlineViewDataSource. I want all the elements to be expanded after they are loaded, but I can’t find the event that was fired after the data loading is completed, so I can send it to him [outlineView expandItem: nil expandChildren: YES].

I looked at the protocol NSOutlineViewDelegate, but I could not find a suitable place for this call. What would be the best approach for this problem?

+5
source share
4 answers

- - awakeFromNib

dispatch_async(dispatch_get_main_queue(), ^{
    [self.outlineView expandItem:root expandChildren:YES];
});

runloop, , . .

+7

, , - , NSOutlineView .

- (void)windowDidLoad
{
    [super windowDidLoad];
    [self performSelector:@selector(expandSourceList) withObject:nil afterDelay:0.0];
}

- (IBAction)expandSourceList
{
    [mSourceListView expandItem:nil expandChildren:YES];
}
+3

. , . , , , . , . " " . , NSApplication:

  • (void) applicationDidFinishLaunching: (NSNotification *) aNotification

, , . : [myWindow makeKeyAndOrderFront: self];. , , , . .

+1
source

I have found the answer. It seems that implementing the delegate method -(void)outlineView:(NSOutlineView *)outlineView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item will do the trick:


-(void)outlineView:(NSOutlineView *)outlineView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item
{
    [outlineView expandItem:item];
}
+1
source

All Articles