Note that there are some explanatory texts on larger screens.

plurals
  1. PODynamic NSOutlineView data source
    text
    copied!<p>So I have implemented a <code>PXSourceList</code> data source that pretty much is a duplicate of Apple's example of a <code>NSOutlineView</code> data source.</p> <p>This is how it goes...</p> <pre><code>- (NSUInteger)sourceList:(PXSourceList*)sourceList numberOfChildrenOfItem:(id)item; { if (item == nil) { // item is nil so it's part of the very top hierarchy. // return how many sections we need. return 2; } else { if ([item class] == [TSFileSystemItem class] ) { return [item numberOfChildren]; // if item isn't nil and it's a TSFileSystemItem, then return it's children. } if ([item class] == [TSWorkspaceItem class]) { return 2; // i don't know, random items. } else { NSLog(@"this is a special object."); } } } - (BOOL)sourceList:(PXSourceList *)aSourceList isItemExpandable:(id)item { if (item == nil) { return YES; } else { // if the number of children of the item is -1 BOOL gibberhook = ([item numberOfChildren] != -1); return gibberhook; } } -(id)sourceList:(PXSourceList *)aSourceList child:(NSUInteger)index ofItem:(id)item { if (item == nil) { return [TSFileSystemItem rootItem]; } else { return [(TSFileSystemItem *)item childAtIndex:index]; } } - (id)sourceList:(PXSourceList *)aSourceList objectValueForItem:(id)item { if (item == nil) { return @"/"; } else { if (item == [TSFileSystemItem rootItem]) { return PROJECT_FILES; } else { return [item relativePath]; } } } </code></pre> <p>The mysterious <code>TSFileSystemItem</code> is from here: <a href="https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/OutlineView/Articles/UsingOutlineDataSource.html" rel="noreferrer">https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/OutlineView/Articles/UsingOutlineDataSource.html</a>. </p> <p>All of this is OK, except I want to divide my source list to have multiple sections (root cells). One displaying a file hierarchy (check) and the other... </p> <p>Well the other is going to contain a <code>NSMutableArray</code> that I add items to from the other section. Sounds complicated? Better explanation. Click an item from section with file hierarchy, and it is added to the other section. </p> <p>I have tried to solve this mess with the help of Apple's docs, but I still can't find a simple, efficient, stable way of making 2 sections with the functions I mentioned above. If only it was as easy as configuring a data source for <code>UITableView</code>... </p> <p>Can anybody kindly help me out?</p>
 

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