Question

I do it like this.

NSDictionary *dictionary = [NSDictionary dictionaryWithObjects:allMyNameObjects forKeys:allMySizeObjects];

allMyNameObjects = {a,b,c,d}

allMySizeObjects = {1,2,1,3}

And is dictionary = {a:1,b:2,d:3}

"c" does not appear, because it has same size with "a".

allMySizeObjects objects has in NSNumber

Why it does not work with the same key? And how to make that work? Thank you all for your help.

Was it helpful?

Solution

NSDictionary keys must be unique.

You can reverse keys with objects

NSDictionary *dictionary = [NSDictionary dictionaryWithObjects:allMySizeObjects forKeys:allMyNameObjects];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top