Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

mpemburn

macrumors member
Original poster
Jan 11, 2008
51
0
Bel Air, MD USA
Hi Folks,

I have a PopupButton on my preferences window that's populated from a custom .plist. The items are entered in properly sorted order but when I pull them out, it looks like this:

50 dpi
450 dpi
150 dpi
1200 dpi
75 dpi
100 dpi
200 dpi
300 dpi
600 dpi
2400 dpi

. . . which is just about random as far as I can tell. Now, I don't want to sort the list with an alpha sort because it'd come out like this:

100 dpi
1200 dpi
150 dpi
200 dpi
2400 dpi
300 dpi
450 dpi
50 dpi
75 dpi
600 dpi

I'm pretty sure there's no "natural sort" mechanism built into Objective-C (which is why I pine for PHP at times like this). Is there any way to tell it to just leave it the heck alone?

Thanks,

-- Mark
 
Hi Folks,


I'm pretty sure there's no "natural sort" mechanism built into Objective-C (which is why I pine for PHP at times like this). Is there any way to tell it to just leave it the heck alone?

Thanks,

-- Mark

Keys are hashed, so there is no order guarantee.

What you could do is keep an NSArray in order with the keys and do your NSDictionary lookups based on that.
 
I'm pretty sure there's no "natural sort" mechanism built into Objective-C (which is why I pine for PHP at times like this). Is there any way to tell it to just leave it the heck alone?

I'm pretty sure you didn't read the NSString documentation. Check out the compare: options: method.
 
gnasher729 -- Thanks, I'll check it out. I've read parts of the documentation for many, many Objective-C classes over the past three months and that doesn't equate to a comprehensive knowledge. Don't have the leisure (or focus) to sit and read the whole thing from start to finish.

-- Woody
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.