views:

24

answers:

2

I have an NSDictionary, with six objects, and the keys a, b, c... etc. What I am doing is removing three objects by their keys, and I don't know what objects are going to be removed, as they are determined by user input, so I could be left with a, d, and e. If this was an array, I could just access the ones left over by using objectAtIndex, but I don't know how I can get at these three leftover objects in a dictionary.

This may seem sort of confusing to see what I want to do here, but I want those leftover objects with keys a, d, and e, for instance, but I won't know their keys, so I need another way of accessing them.

+1  A: 

Simply use the allKeys method on your dictionary, which returns an NSArray *.

Martin Cote
+1  A: 

-[NSDictionary allValues] will get you all the values. Or Martin's suggestion if you want all the keys.

Firoze Lafeer
So that returns an array with pointers to all the objects?
Regan
Yes, that's right.
Firoze Lafeer