I was wondering what this convenience method stood for but was unable to find any answers for it.
What exactly does theDictionary[@"key"] do when wanting to extract a value from a dictionary? Is it using valueForKey: or objectForKey:?
What is better performance wise? Is it better to write the whole message like [theDictionary objectForKey:@"key"] or is the convenience method sufficient?
NSDictionaryprovides the methodobjectForKey:to access its contents. The difference tovalueForKey:is explained in depth in this related question: Difference between objectForKey and valueForKey?.The
[]operator is a shortcut toobjectForKey:. Whichever you use doesn't really matter, but the former one is easier to read (less code noise), instantly clear in its intention, and you don't have to think about whether it'sobjectForKey:orvalueForKey:.So personally, I much prefer
[].