I have an NSOutlineView that I want to populate with a list of NSURL objects. I have this working in NSTableView. As a first step toward moving to NSOutlineView (so that I can group the NSURL objects by various criteria as the user wants) I implemented the NSOutlineViewDataSource protocol's minimum methods in a way that should mimic the table view:
- (NSInteger)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item {
if(!item) return [[self.resultsArrayController arrangedObjects] count];
return 0;
}
- (id)outlineView:(NSOutlineView *)outlineView child:(NSInteger)index ofItem:(id)item {
if(!item){
return [[self.resultsArrayController arrangedObjects] objectAtIndex:index];
}
}
- (id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item {
return [item valueForKey:[tableColumn identifier]];
}
- (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item {
return NO;
}
This keeps throwing an unrecognized selector exception showing [NSURL indexPath]
is being called. Anyone have an idea why this method is being called or how to work around it?
I'm not sure it's your case, but I have faced the very same issue with the NSOutlineView when I binded the Selection Index Paths of the outline to the my Controller. After that NSOutlineView tried to query the indexPath method of the items every time I selected an item.
I suppose this binding is intended to be used in combination with the NSTreeController. At least it worked fine when I had one. At the moment, the only solution I can find is to avoid using the binding at all or use it with the NSTreeController.