So I have implemented a PXSourceList
data source that pretty much is a duplicate of Apple's example of a NSOutlineView
data source.
This is how it goes...
- (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];
}
}
}
The mysterious TSFileSystemItem
is from here: https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/OutlineView/Articles/UsingOutlineDataSource.html.
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...
Well the other is going to contain a NSMutableArray
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.
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 UITableView
...
Can anybody kindly help me out?