• 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: How to control the order of enumerating on a NSDictionary
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >How to control the order of enumerating on a NSDictionary (From: JArod Wen <email@hidden>)
 >Re: How to control the order of enumerating on a NSDictionary (From: Graham Cox <email@hidden>)

  • Prev by Date: Text Fields not Updating when Overridden setNilValueForKey: Called
  • Next by Date: Re: How to control the order of enumerating on a NSDictionary
  • Previous by thread: Re: How to control the order of enumerating on a NSDictionary
  • Next by thread: Re: How to control the order of enumerating on a NSDictionary
  • Index(es):
    • Date
    • Thread