NSMutableDictionary with capacity
What happens when you try to add to an NSMutableDictionary once it h开发者_运维百科as already reached its capacity limit of objects? Does this bump one out or is this going to throw an exception? Also is there any way to have it bump out the oldest dictionary object when I add a new one?
It bumps it up. The capacity in the constructor is only the initial capacity.
This page has the following snippet:
initWithCapacity:
: : : : :
Discussion: Mutable dictionaries allocate additional memory as needed, so numItems simply establishes the object’s initial capacity.
精彩评论