Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the Java equivalent of Objective-C's NSDictionary?

What is the closest implementation of Objective-C's NSDictionary in Java? To me, it looks like HashMap<String, Object>, but I'm very new to Objective-C.

Thanks

like image 208
tyler Avatar asked Nov 14 '11 21:11

tyler


People also ask

What is NSDictionary?

An object representing a static collection of key-value pairs, for use instead of a Dictionary constant in cases that require reference semantics.

Does NSDictionary retain objects?

An NSDictionary will retain it's objects, and copy it's keys.


1 Answers

NSDictionary is a class cluster (see the "Class Cluster" section in The Cocoa Fundamentals Guide), meaning that the actual implementation is hidden from you, the API user. In fact, the Foundation framework will choose the appropriate implementation at run time based on amount of data etc. In addition, NSDictionary can take any id as a key, not just NSString (of course, the -hash of the key object must be constant).

Thus, closest analog is probably Map<Object,Object>.

like image 183
Barry Wark Avatar answered Oct 02 '22 01:10

Barry Wark