What happens when you try to add to an NSMutableDictionary once it has 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?
+1
A:
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.
paxdiablo
2010-08-23 05:08:40
Oh that makes sense. I wish it didn't work that way but it makes sense. Thanks!
Alexander
2010-08-23 05:10:03
@Alexander, ask and ye shall receive :-) Since I couldn't find an answer to your "I wish it didn't work that way" comment, the best thing to do is ask a question: http://stackoverflow.com/questions/3544914/how-can-we-limit-the-capacity-of-an-nsmutabledictionary I'll leave that for a couple of days for you to check out the answers. If you officially "bless" one of the answers with a comment stating you think it's the best, I'll accept that one. Otherwise I'll let the SO swarm decide. Cheers.
paxdiablo
2010-08-23 05:45:33
Oh my gosh thank you so much! That is so nice! Ok I will watch that. Thanks again very much!!!
Alexander
2010-08-23 06:15:06