iphone数组与字典的索引
我有一个带有字典的数组,
.如何获取特定字典的索引...[我在其中获取了我想要查找的字典的数据,但需要打开索引]
NSMutableDictionary *dictois = [[NSMutableDictionary alloc]init];
[dictois setObject:@"easySpritedd" forKey:@"Nombre"];
[dictois setObject:@"X" forKey:@"290"];
[dictois setObject:@"Y" forKey:@"300"];
int fooIndex = [self.bloquesArray indexOfObject: dictois];
但正如你所见,我还不知道如何获取字典以在对象索引
谢谢!
i have an array with dictionaries,
. how to get the index for a specific dictionary... [where I got the data for the dictionary i want to find, but need the index is on]
NSMutableDictionary *dictois = [[NSMutableDictionary alloc]init];
[dictois setObject:@"easySpritedd" forKey:@"Nombre"];
[dictois setObject:@"X" forKey:@"290"];
[dictois setObject:@"Y" forKey:@"300"];
int fooIndex = [self.bloquesArray indexOfObject: dictois];
but as you see i dont know yet how to get the dictionary for comparing in the indexOfObject
thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
NSDictionary对象有以下比较方法:
有以下讨论
您应该属于这种情况。遗憾的是,您无法更改 NSArray 用于计算 indexOfObject 的方法:因此它无法帮助您,因此 Denis 提供的解决方案是我能想到的最好的解决方案(除非您喜欢子类化 NSArray,但我不推荐)。
作为对 Denis 答案的补充,您可以使用 NSArray 方法
而不是
如果数组中有多个相等的对象是可能的。
NSDictionary objects have the following comparison methods:
With the following discussion
This should be the case for you. Sadly you cannot change the method which NSArray uses to calculate the indexOfObject: so it can't help you, hence the solution provided by Denis is the best I can think of (unless you fancy subclassing NSArray which I wouldn't recommend).
Just as a complement to Denis' answer you could use the NSArray method
instead of
If having several equal objects in the array is a possibility.
使用以下代码
Use the following code