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

Re: Odd NSDictionary Problem


  • Subject: Re: Odd NSDictionary Problem
  • From: Christopher Corbell <email@hidden>
  • Date: Tue, 22 Jul 2003 23:29:49 -0700

On Tuesday, July 22, 2003, at 10:26 PM, email@hidden wrote:

Hello,

I have an odd (or maybe not so odd, I dunno) NSDictionary problem.

Ok, I have two NSMutableDictionarys.
During a 'for' loop, i do something like this:

-----------------------------------------------------
[dictionaryOne setObject:A forKey:B];
[dictionaryTwo setObject:B forKey:A];

int x = [dictionaryOne count];
int y = [dictionaryTwo count];
----------------------------------------------------

Object A and B change every loop. When I look at the counts of both dictionaries, they are not the same. One dictionary has 2 more entries than the other. Shouldn't they both come out the same?

-Alex P.

Just a hunch - are you sure that you never get a duplicate key value (either
A or B) in your loop?

Whichever dictionary has fewer entries - say it's #1, which uses B as its
key - check that key value for duplicates (log a description to the console
or something). If you set an object for a key that already exists, the dictionary
will just replace the object previously assigned with the new one. Since
you're assigning different objects as keys to the two dictionaries, that could
account for the size difference.

If that doesn't prove to be the problem, you might post more code...

- Christopher
_______________________________________________
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: 
 >Odd NSDictionary Problem (From: email@hidden)

  • Prev by Date: Re: flummoxed by math failure
  • Next by Date: Re: Can a subclass of NSDictionary do this?
  • Previous by thread: Odd NSDictionary Problem
  • Next by thread: Re: Bug reports and documentation updates (was Re: Subclassing NSPort (or NSSocketPort))
  • Index(es):
    • Date
    • Thread