Pregunta

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.

¿Fue útil?

Solución

NSDictionary keys must be unique.

You can reverse keys with objects

NSDictionary *dictionary = [NSDictionary dictionaryWithObjects:allMySizeObjects forKeys:allMyNameObjects];
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top