Domanda

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.

È stato utile?

Soluzione

NSDictionary keys must be unique.

You can reverse keys with objects

NSDictionary *dictionary = [NSDictionary dictionaryWithObjects:allMySizeObjects forKeys:allMyNameObjects];
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top