如何从NSMutableDictionary获取给定对象的密钥? [英] How to get the key for a given object from an NSMutableDictionary?

查看:103
本文介绍了如何从NSMutableDictionary获取给定对象的密钥?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个大的NSMutableDictionary中的对象,需要找出它有哪个键。所以我想从两个列中查找表。不仅有键,还有对象(获取键)。这可能吗?

I have an object which is in an big NSMutableDictionary, and need to find out which key this has. So I want to look up that "table" from both columns. Not only with keys, but also with objects (to get keys). Is that possible?

推荐答案

查看父类(NSDictionary)

Look to the parent class (NSDictionary)

- (NSArray *)allKeysForObject:(id)anObject

将返回给定对象值的所有键的NSArray。 BUT 它通过向Dictionary的每个对象发送一条isEqual消息来实现这一点,因此对于您的大型数据集,这可能不是最佳性能。

Which will return a NSArray of all the keys for a given Object Value. BUT it does this by sending an isEqual message to each object of the Dictionary so for your large dataset this may not be best performance.

也许您需要保留某种形式的附加索引结构结构,以允许您在其中的某些关键值上定位对象,链接到密钥而无需直接对象比较

Maybe you need to hold some form of additional indexing structure structure(s) to allow you to locate the objects on some critical values within them, linked to the key without direct object comparison

这篇关于如何从NSMutableDictionary获取给定对象的密钥?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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