• 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: Clark Mueller <email@hidden>
  • Date: Sat, 25 Jan 2003 11:30:57 -0700

I did not say that implementing a browser was hard, I said that there's a lot of work for very little in return. Perhaps to be more accurate, NSBrowser requires a lot of work to get anywhere beyond the base browser that you see when you drag and drop in IB. It's probably true what was said about it lacking, especially in comparison to the Finder's implementation. I suppose it's fair to say that in order to stay ambiguous about where it can be used, Apple has kept it simple. I don't think though, that it only needs to be solidified and polished, I think it would benefit from having some flexibility options added to it. Individually resizable columns are one example. Even something as simple as the user being able to create an empty selection just by clicking in the empty spot at the bottom of a column that's not quite full, rather than having to individually deselect each selected item, is a very trivial thing that isn't there by default in an NSBrowser.

And no, I don't think that writing a replacement class is easier. It's harder, obviously, but it also allows for me to do *exactly* what I want, and I don't mind doing the extra work. That said, I have yet to write a replacement for it for my own use. I've left NSBrowser alone as is for the time being; it'll be a little while before that's what I have to worry about in my app.

Clark

On Saturday, January 25, 2003, at 03: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.

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.
_______________________________________________
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.

References: 
 >Re: NSBrowser: so very, very broken (From: j o a r <email@hidden>)

  • Prev by Date: Re: cascading sheets and HIG
  • Next by Date: Re: Localizable.strings German Problem
  • Previous by thread: Re: NSBrowser: so very, very broken
  • Next by thread: Re: NSBrowser: so very, very broken
  • Index(es):
    • Date
    • Thread