NSDictionary与Swift中的Dictionary之间有什么区别? [英] What is difference between NSDictionary vs Dictionary in Swift?

查看:790
本文介绍了NSDictionary与Swift中的Dictionary之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习Swift,我可以看到字典

但是有很多使用 NSDictionary 与Swift。

这两者有什么区别?

我想使用一个索引的数组Swift喜欢PHP中的一个数组。

哪个更好使用?

I'm learning Swift, and I can see Dictionary in it.
But there are lots of examples that are using NSDictionary with Swift.
What's the difference between these two?
I want to use an array with index in Swift like an array in PHP.
Which one is better to use?

推荐答案

词典是一个本机的Swift结构体。 NSDictionary是一个Cocoa类。它们相互桥接(在通常的限制内),正如文档解释非常清楚和完整的。

Dictionary is a native Swift struct. NSDictionary is a Cocoa class. They are bridged to one another (within the usual limits), as the docs explain very clearly and fully.

它与Array和NSArray完全相同。

It's exactly parallel to Array and NSArray.

这篇关于NSDictionary与Swift中的Dictionary之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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