Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This question turned out to be a real tumbleweed (my second in one month) so I wanted to follow up with some more info. I ended up using the above posted code for flattening my NSOutlineView as I was unable to find a better option. When you have to recursively iterate through an unknown number of subfolders (in my case) this seems to be the best option where the <code>descendants</code> method is called for each time you reach a deeper level. I found a very useful website with a number of useful NSTreeController extensions <a href="https://wabbit.svn.codeplex.com/svn/Wabbitstudio/Mac/WabbitStudio/WabbitCode/NSTreeController+WCExtensions.m" rel="nofollow">here</a>, which uses the same approach as I had taken. Unless someone helps me figure out a faster and better algorithm for flattening the arrangedObjects of a NSTreeController, I believe i will stick with this approach.</p> <p>Cheers, Trond</p> <p><strong>Update:</strong> After a question for the solution I decided to post my method for how to flatten an outlineview. I hope his can help others.</p> <pre><code>- (void) flattenOutlineview { NSMutableArray *nodeArray = [NSMutableArray array]; [self.myFlattenedFiles removeAllObjects]; [self.myFlattenedNodes removeAllObjects]; [self.myIndexDict removeAllObjects]; [nodeArray removeAllObjects]; for (SDNode *rootnode in self.rootNodes) { [nodeArray addObject:rootnode]; [self.myIndexDict setObject:[rootnode indexPath] forKey:[[[rootnode representedObject] representedObject] fullpathL]]; for (SDNode *node in [rootnode childNodes]) { if (node.isLeaf){ [nodeArray addObject:node]; [self.myIndexDict setObject:[node indexPath] forKey:[[[node representedObject] representedObject] fullPathCopy]]; } else { [nodeArray addObjectsFromArray:[self descendants:node]]; [self descendantsIndex:node]; } } } [self.myFlattenedNodes setArray:[nodeArray copy]]; for (SDNode *node in self.myFlattenedNodes) { [self.myFlattenedFiles addObject:[[node representedObject] representedObject]]; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload