Confusing one to explain: I’m trying to iterate a for loop through an NSMutableDictionary, looking at its “key” values, and comparing those to the “key” values of a second NSMutableDictionary. If there’s a match (they’re string comparisons), I want the “object” of both dictionaries to be added to a separate array.
To clarify, Dictionaries A and B both contain lists of words (object) and those words in alphabetical order (key), like so:
apple = aelpp
tomato = amoott
stack = ackst
So I need to compare “aelpp” to “amoott”, but then store “apple” and “tomato”.
Basic question is: when using a for loop (for (NSString *currentWord in dictionaryA)), how do I refer to dictionaryA’s objects or keys specifically? I’ll need it to compare the keys, but then store the objects if they’re a match.
If anything needs more clarification, please do ask 🙂
To answer your “basic question”: Fast enumeration of an
NSDictionaryenumerates the dictionary keys:(assuming that all keys and values are strings).