Re: NSPopUpButton addItemsWithTitles is way slow
Re: NSPopUpButton addItemsWithTitles is way slow
- Subject: Re: NSPopUpButton addItemsWithTitles is way slow
- From: Jeremy Dronfield <email@hidden>
- Date: Fri, 16 Aug 2002 13:37:27 +0100
On Friday, August 16, 2002, at 01:54 am, Dave Camp wrote:
There must be a way of doing this without a performance penalty. What
am I doing wrong?
The main thing you're doing "wrong" is going against Apple's interface
guidelines, which recommend NSPopUpButtons for lists with 5-12 items.
20-50 items is pushing it, whereas 200 items...? For big collections,
they suggest using a scrollable list, unless window space is a serious
problem.
All NSPopUpButton methods for adding/removing items call
-synchronizeTitleAndSelectedItem, which logically has to search for and
remove any duplicates. With 200 items there's inevitably going to be a
time penalty. You could try calling the equivalent -add methods for
NSPopUpButtonCell (which - I think - don't sychronize), but I'm not sure
how you'd go about it, and Apple recommends against doing it.
BTW, I posted the code you adapted. It's intended for an NSMenu, where
there's no synchronization issue. I adapted it from the MenuMadness
example project. If performance is a big issue, and you don't have space
for a scrollable list, I'd suggest putting your countries list in an
NSMenu.
-Jeremy
=======================================
email@hidden // email@hidden
The Alchemy Pages:
- fractious fiction at
http://freespace.virgin.net/jeremy.dronfield
_______________________________________________
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.