是NSMutableDictionary的字面创建比类辅助方法效率低吗? [英] Is literal creation of an NSMutableDictionary less efficient than the class helper method?

查看:120
本文介绍了是NSMutableDictionary的字面创建比类辅助方法效率低吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用构造函数

[NSMutableDictionary dictionaryWithObjectsAndKeys:@"object1", @"key1", @2, @"key2", nil];

比获取文字的可变拷贝

[@{@"key1":@"object1", @"key2":@2} mutableCopy];


推荐答案

没有看到源代码,我可以想到为什么要更快的可能原因

Without looking at the source, I can think of possible reasons why either might be faster and that answer may change depending on # of entries.

真正的问题是,为什么你有一个应用程序架构在哪里重要?很少有一个应用程序创建这么多可变字典(或者字典太大),这是一个性能问题。

The real question, though, is why do you have an app architecture where it matters? It is quite rare to have an application that is creating so many mutable dictionaries (or dictionaries so large) that it is a performance issue.

这篇关于是NSMutableDictionary的字面创建比类辅助方法效率低吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆