How do I use NSEnumerator with NSMutableDictionary, to print out all the keys and values?
Thanks!
Unless you need to use NSEnumerator, you can use fast enumeration (which is faster) and concise.
for(NSString *aKey in myDictionary) {
NSLog(@"%@", aKey);
NSLog(@"%@", [[myDictionary valueForKey:aKey] string]); //made up method
}
Also you can use an Enumerator with fast enumeration:
NSEnumerator *enumerator = [myDictionary keyEnumerator];
for(NSString *aKey in enumerator) {
NSLog(@"%@", aKey);
NSLog(@"%@", [[myDictionary valueForKey:aKey] string]); //made up method
}
This is useful for things like doing the reverse enumerator in an array.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With