• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSBrowser: so very, very broken
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSBrowser: so very, very broken


  • Subject: Re: NSBrowser: so very, very broken
  • From: j o a r <email@hidden>
  • Date: Sat, 25 Jan 2003 11:40:26 +0100

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.

The only difficulty is matching the column-row coordinate to a node in the tree. Let's say that you have the data for the browser structured as an array of dictionaries, where each dictionary in turn can have an array of children as dictionaries, etc., etc... I would have a support method looking something like this:

- (NSArray *) browser:(NSBrowser *) browser itemsForColumn:(int) column
{
NSArray *items = [self root];

int i;
for (i = 0; i < column; i++)
{
int index = [browser selectedRowInColumn: i];
items = [[items objectAtIndex: index] objectForKey: ITEM_CHILDREN];
}

return items;
}

...after which implementing the other delegate methods is trivial - for example:

- (int) browser:(NSBrowser *) sender numberOfRowsInColumn:(int) column
{
return [[self browser: sender itemsForColumn: column] count];
}

- (void) browser:(NSBrowser *) sender willDisplayCell:(id) cell atRow:(int) row column:(int) column
{
NSDictionary *item = [[self browser: sender itemsForColumn: column] objectAtIndex: row];

[cell setStringValue: [item objectForKey: ITEM_NAME]];
[cell setLeaf: ([item objectForKey: ITEM_CHILDREN] == nil)];
}

If you think implementing the delegate for a NSBrowser compares to the work involved with writing a replacement class, I think you're wrong - and also probably missing some understanding of how NSBrowser delegates works.

That said, I agree with some of the sentiments in the first post in this thread in that I don't think that NSBrowser feel as "solid and polished" as I would have liked. Given a chance to redesign the class somewhat, I think it could be much better - but as John points out, that's not easy or perhaps even possible, given that it would break existing code.

j o a r
_______________________________________________
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.

  • Follow-Ups:
    • Re: NSBrowser: so very, very broken
      • From: "John C. Randolph" <email@hidden>
    • Re: NSBrowser: so very, very broken
      • From: Clark Mueller <email@hidden>
References: 
 >Re: NSBrowser: so very, very broken (From: Clark Mueller <email@hidden>)

  • Prev by Date: nstablecolumns in nstableviews in an nssplitview
  • Next by Date: hypercard-style framework/library
  • Previous by thread: Re: NSBrowser: so very, very broken
  • Next by thread: Re: NSBrowser: so very, very broken
  • Index(es):
    • Date
    • Thread