Re: How to control the order of enumerating on a NSDictionary
Re: How to control the order of enumerating on a NSDictionary
- Subject: Re: How to control the order of enumerating on a NSDictionary
- From: JArod Wen <email@hidden>
- Date: Sun, 24 Aug 2008 23:39:36 -0400
Thanks man, I got your idea.
On Aug 24, 2008, at 7:43 PM, Graham Cox wrote:
On 25 Aug 2008, at 9:36 am, JArod Wen wrote:
It should be the problem when enumerating the dictionary, right?
How can I control the order of enumerating?
You can't if you enumerate the keys directly - there is no concept
of "order" for the items of a dictionary. But you can copy them into
a mutable array and sort it as you wish, then enumerate that.
I got the key-value pairs in NSDictionary as following:
"ang (A)" = 2;
"dis (D)" = 1;
"pos (P)" = 0;
"shp (S)" = 3;
Maybe a dictionary isn't the right data structure for the task at
hand? An array might be more appropriate, as it includes the concept
of "order". You appear to be using the dictionary keys to look up an
integer position. Instead, why not just store the column names in an
array where the index is the position?
hth,
Graham
---------------
JArod Wen
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden