What is difference between NSDictionary vs Dictionary in Swift?

TomSawyer picture TomSawyer · Aug 28, 2014 · Viewed 14.8k times · Source

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?

Answer

matt picture matt · Aug 28, 2014

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.

It's exactly parallel to Array and NSArray.