Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Need to force Lex-Order?



On Thursday, July 31, 2003, at 10:39 PM, Michael Hanna wrote:

Hello, I've written a Dictionary in plist format, in which I need to access the NSArrays in lex-order. However when I get allKeys:

You cannot depend on dictionary keys being stored or returned in any particular order.

Assuming that your dictionary keys are strings, as they appear to be, you can easily get a sorted list of keys with:

keyArray = [[theDict allKeys] sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];

If your keys are other object types, you'll need to use some other sortedArray... variant, but the principle will be the same.

sherm--
_______________________________________________
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: 
 >Need to force Lex-Order? (From: Michael Hanna <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.