• 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: NSDictionary ordering
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSDictionary ordering


  • Subject: Re: NSDictionary ordering
  • From: Daniel Todd Currie <email@hidden>
  • Date: Sun, 21 Sep 2003 22:36:49 -0700

I see you talk about the allKeys method... If all you want is for the keys to be ordered, you can use the keysSortedByValueUsingSelector: method, and it will order the keys into an array based on the values in the dictionary.

// Daniel Currie


On Sunday, September 21, 2003, at 10:00 PM, email@hidden wrote:

Message: 2
Date: Sun, 21 Sep 2003 14:09:03 -0600
Subject: Re: NSDictionary ordering
From: Tom Harrington <email@hidden>
To: email@hidden

On Sunday, September 21, 2003, at 11:46 AM, Anders Totland wrote:
I know this is a kind of dumb question, but will the allKeys method of
an NSDictionary reliably return the same order if the dictionary is
unchanged?
Is there any kind of logic to their order?
Will the dictionary {A = anObject; B = anoherObject; C =
yetAnotherObject } return the same allKeys in ACocoaApp at seven in the
morning and AnotherCocoaApp at three in the evening?
If the one is loaded from a plist and the other is created
programaticcally?

In practice, probably yes. But since the docs specifically say that
the order's not defined, it'd be extremely unwise to rely on this
behavior.

Is there any kind of ordered dictionary, i.e. where the keys of allKeys
are a set, but also ordered?

Not built in. It probably wouldn't be too hard to roll your own, a
class that used NSDictionary and also maintained ordering info.

--
Tom Harrington
email@hidden

--__--__--
_______________________________________________
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.

  • Prev by Date: Re: not a complete newbie question....
  • Next by Date: Re: Sample Code
  • Previous by thread: Re: NSDictionary ordering
  • Next by thread: notifications questions
  • Index(es):
    • Date
    • Thread