Re: NSBrowser: so very, very broken
Re: NSBrowser: so very, very broken
- Subject: Re: NSBrowser: so very, very broken
- From: "John C. Randolph" <email@hidden>
- Date: Sat, 25 Jan 2003 20:46:34 -0800
On Saturday, January 25, 2003, at 02:40 AM, j o a r wrote:
On Saturday, Jan 25, 2003, at 01:54 Europe/Stockholm, Clark Mueller
wrote:
I pretty much went into cardiac arrest after I found out how much
work NSBrowser involves for so little in return. I've gone about
writing all of the stuff I need almost completely from scratch.
NSBrowser simply doesn't pull its weight for most of the places in
which it might be practically applied. It's annoying.
I beg to differ. Provided that you already have a tree of data - the
prerequisite for a browser / outline view - the implementation of the
delegate / data source for a browser is _not_ much more cumbersome or
even different than the code you have to write for a table view.
[code example snipped]
I'll just mention as well, that when I wrote my Obj-C runtime hierarchy
browser back before I took this job at Apple, my browser delegate
methods came to just:
@implementation RuntimeBrowserDelegate
- (int)browser:(NSBrowser *)sender numberOfRowsInColumn:(int)column;
{
ClassEnumerator
*enumerator = (column == 0 ? [ClassEnumerator rootClassEnumerator]
:
[ClassEnumerator
subclassEnumeratorForClass:NSClassFromString([[sender
selectedCellInColumn:column-1] title])]);
return [enumerator countRemainingObjects];
}
- (void)browser:(NSBrowser *)sender willDisplayCell:(id)cell
atRow:(int)row column:(int)column
{
NSArray
*classNames = (column == 0 ?
[[ClassEnumerator rootClassEnumerator] sortedNames] :
[ClassEnumerator sortedSubclassNamesForClassNamed:[[sender
selectedCellInColumn:column-1] title]]);
[cell setTitle:[classNames objectAtIndex:row]];
[cell setLeaf:!classHasDescendants(NSClassFromString([cell title]))];
}
@end
The bulk of the work was implementing my ClassEnumerator class (which
is still only about 300 lines of code, including a bunch of stuff for
caching lookups already performed, etc.)
-jcr
John C. Randolph <email@hidden> (408) 974-8819
Sr. Cocoa Software Engineer,
Apple Worldwide Developer Relations
http://developer.apple.com/cocoa/index.html
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.