Objective-C 的 NSDictionary 的 Java 等价物是什么? [英] What is the Java equivalent of Objective-C's NSDictionary?

查看:29
本文介绍了Objective-C 的 NSDictionary 的 Java 等价物是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Objective-C 的 NSDictionary 在 Java 中最接近的实现是什么?对我来说,它看起来像 HashMap<String, Object>,但我对 Objective-C 很陌生.

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.

谢谢

推荐答案

NSDictionary 是一个类簇(参见 The Cocoa Fundamentals Guide),这意味着实际的实现对你是隐藏的,API用户.事实上,Foundation 框架会在运行时根据数据量等选择合适的实现.另外,NSDictionary 可以将任何 id 作为 key,而不仅仅是 NSString(当然key对象的-hash必须是常量).

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).

因此,最接近的模拟可能是 Map.

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

这篇关于Objective-C 的 NSDictionary 的 Java 等价物是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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