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

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

问题描述

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

感谢

解决方案

NSDictionary 是一个类集群(请参阅类可以在 Cocoa基础知识指南),这意味着实际的实现对您来说是API用户隐藏的。事实上,Foundation框架将根据数据量等选择合适的实现。另外, NSDictionary 可以接受任何 id 作为关键字,而不仅仅是 NSString (当然,关键对象的 -hash 必须因此,最接近的模拟可能是 Map< Object,Object>


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

解决方案

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

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

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