具有容量的 NSMutableDictionary

发布于 2024-09-15 17:05:02 字数 109 浏览 3 评论 0原文

当 NSMutableDictionary 已经达到其对象容量限制时,当您尝试添加到它时会发生什么?这是否会导致一个异常,或者是否会引发异常?当我添加新字典对象时,有什么方法可以让它淘汰最旧的字典对象吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

烟酉 2024-09-22 17:05:02

它把它颠倒了。构造函数中的容量只是初始容量。

此页面有以下代码片段:

initWithCapacity:
<代码>::::::
讨论:可变字典根据需要分配额外的内存,因此 numItems 只是建立对象的初始容量。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文