• 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 allKeys and allValues clarification?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSDictionary allKeys and allValues clarification?


  • Subject: Re: NSDictionary allKeys and allValues clarification?
  • From: Robert Walker <email@hidden>
  • Date: Thu, 5 Jan 2006 08:40:06 -0500

I haven't actually tested this, but I'm pretty sure that the two arrays will be ordered the same. The keys and values are in an undefined ordering, but value at index 0 should be the value for the key at index 0.

However, it's probably safer to iterate over the keys and pull the values out using objectForkey:

Should be fairly easy for you to test this to verify.

On Jan 5, 2006, at 8:28 AM, Matt Gough wrote:

OK, so the documentation for allKeys and allValues both state:

'The order of the elements in the array isn’t defined'.

Does that really mean that if i do:

NSArray* keys = [dict allKeys];
NSArray* values = [dict allValues];

that there is no guarantee that the items in the two arrays are in sync with each other.

Should I really be doing:

NSArray* keys = [dict allKeys];

NSArray* values = [dict objectsForKeys:keys notFoundMarker:[NSNull null]];

Thanks

Matt Gough

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40mac.com


This email sent to email@hidden

_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >NSDictionary allKeys and allValues clarification? (From: Matt Gough <email@hidden>)

  • Prev by Date: Re: MainMenu
  • Next by Date: Re: NSDictionary allKeys and allValues clarification?
  • Previous by thread: NSDictionary allKeys and allValues clarification?
  • Next by thread: Re: NSDictionary allKeys and allValues clarification?
  • Index(es):
    • Date
    • Thread