Is there any way to create a mutable dictionary with a capacity limit rather than an initial capacity?
Say you want to create a dictionary that will only ever have, at most, 100 entries.
The capacity argument for the dictionary is an initial capacity that will be simply increased if you add more elements than you want so it’s not suitable.
Subclass it and override addObject to check count before adding? No built-in way.
Here is a basic example… not tested, missing init etc, but this is the core. You should also override setValue:forKey: in a similar manner.