objective c - NSOutlineView shows only first 2 levels of the NSTreeController hierarchy -


i'm populating nsoutlineview nstreecontroller.

the nstreecontroller 3 levels hierarchy controller (cbmovie, cbdisc , cbepisode), first 2 levels displayed in outline view.

the implementation same objects: i've implemented methods specify children, children count , if object leaf. these methods correctly called objects (also ones not displayed, grandchildren: cbepisode).

in outline view, displayed correctly first 2 level. grandchildren never displayed, don't have option expand parent see them. can see cbmovie , cbdiscs.

i'm wondering if there setting i'm missing, how deep nodes can expand in nstreecontrollers or nsoutlineview configurations.

below: implementation in 1 of 3 nodes. each node class has different path children. specified in -(nsarray*)children method (correctly called).

-(nsarray*)children {     return [[self episodes] allobjects]; }  -(int)childrencount {     return [[self episodes] count]; }  -(bool)isleaf {     return ![[self episodes] count]; } 

output of logging code. datasource, nstreecontroller, seems have correct structure.

   cbmovie       cbdisc          cbepisode          cbepisode     cbmovie        cbdisc        cbdisc        cbdisc        cbdisc     cbmovie        cbdisc            cbepisode            cbepisode 

this how populate nsoutlineview (cell based). don't use datasource methods, i'm binding programmatically.

nsmutabledictionary *bindingoptions = [[nsmutabledictionary alloc] initwithcapacity:2];          if (metadata.valuetransformer) {             [bindingoptions setobject:metadata.valuetransformer forkey:nsvaluetransformernamebindingoption];         }         [bindingoptions setobject:[nsnumber numberwithbool:no] forkey:nscreatessortdescriptorbindingoption];         [bindingoptions setobject:[nsnumber numberwithbool:no] forkey:nsraisesfornotapplicablekeysbindingoption];          [newcolumn bind:@"value" toobject:currentitemsarraycontroller withkeypath:[nsstring stringwithformat:@"arrangedobjects.%@", metadata.columnbindingkeypath] options:bindingoptions]; 

examining nstreecontroller side

the nstreecontroller 3 levels hierarchy controller, first 2 levels displayed in outline view.

have confirmed 3 levels loaded nstreecontroller? logging contents console extension below. if output produced code matches appears in outline-view, problem on nstreecontroller side, not outline-view.

#import "nstreecontroller+logging.h"  @implementation nstreecontroller (logging)  // make sure declared in associated header file. -(void)logwithblock:(nsstring * (^)(nstreenode *))block {      nsarray *topnodes = [self.arrangedobjects childnodes];     [self lognodes:topnodes withindent:@"" usingblock:block]; }  // internal use only. -(void)lognodes:(nsarray *)nodes      withindent:(nsstring *)indent      usingblock:(nsstring * (^)(nstreenode *))block {      (nstreenode * each in nodes) {         nslog(@"%@%@", indent, block(each));         nsstring *newindent = [nsstring stringwithformat:@"  %@", indent];         [self lognodes:each.childnodes withindent:newindent usingblock:block];     } }  @end 

the above code not need adjusted, need call customised block:

-(void)logit {      [self.treecontroller logwithblock:^nsstring *(nstreenode * node) {          // called every node in tree. implementation         // see object's description logged console - may         // want more elaborate.         nsstring *description = [[node representedobject] description];         return description;     }];  } 

examining nsoutlineview side

if data seems have loaded correctly nstreecontroller have @ how nsoutlineview populated. delegate method -[nsoutlineviewdelegate outlineview:viewfortablecolumn:item] place start. item argument nstreenode instance, so, before return relevant view can @ node , make sure it's behaving expected. in case, should scrutinize properties of item objects representing cbdisc objects. (you may need click on disclosure buttons method fire relevant objects.)

-(nsview *)outlineview:(nsoutlineview *)outlineview     viewfortablecolumn:(nstablecolumn *)tablecolumn                   item:(id)item {      nstreenode *node = (nstreenode *)item;     nsmanagedobject *representedobject = (nsmanagedobject *)node.representedobject;      // query node     nslog(@"%@ <%@>", representedobject.description, [representedobject class]);     nslog(@"  node leafnode: %@", node.isleaf ? @"yes" : @"no");     nslog(@"  node has child-count of: %lu", (unsigned long)node.childnodes.count);      // query nsmanagedobject     // stuff here...      // app-specific - you'll need change identifier.     return [outlineview makeviewwithidentifier:@"standardtablecellview" owner:self]; } 

Comments