OGeek|极客世界-中国程序员成长平台

标题: ios - 双向结构的可用性? [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 03:12
标题: ios - 双向结构的可用性?

我在我的应用程序中遇到了一个需要双向字典数据结构的情况,这意味着一种 NSDictionary,您可以在其中检索带有值的键和带有键的值(所有值和键都是唯一的) .

C/ObjectiveC 中有这样的数据结构吗?



Best Answer-推荐答案


您可以使用 NSDictionary:

allKeysForObject: Returns a new array containing the keys corresponding to all occurrences of a given object in the dictionary.

Discussion Each object in the dictionary is sent an isEqual: message to determine if it’s equal to anObject.

还有:

objectForKey: Returns the value associated with a given key.

关于ios - 双向结构的可用性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17718241/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4