从NSArray中检索NSDictionary,其中字典键的值为X. [英] Retrieve NSDictionary from NSArray where dictionary key has value X
本文介绍了从NSArray中检索NSDictionary,其中字典键的值为X.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有 NSArray
, NSDictionaries
。其中一个数组中的一个字典键包含一个值。我想检索带有该值的 NSDictionary
。
I have an NSArray
with NSDictionaries
. One of the dictionaries keys in one of the arrays contains a value. I want to retrieve the NSDictionary
with that value.
我的数组:
Array: (
{
DisplayName = "level";
InternalName = "Number 2";
NumberValue = 1;
},
{
DisplayName = "PurchaseAmount";
InternalName = "Number 1";
NumberValue = 3500;
}
)
所以,我想得到包含 DisplayName <的字典/ code>设置为
PurchaseAmount
(不区分大小写)。
So, I would like to get the dictionary which contains DisplayName
set to PurchaseAmount
(case insensitive).
我该如何实现?
推荐答案
LIKE [cd]也会这样做
LIKE[cd] will also do it
NSArray *filtered = [data filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"(DisplayName LIKE[cd] %@)", @"purchaseAmount"]];
返回
<NSArray>(
{
DisplayName = PurchaseAmount;
InternaName = "Number 1";
NumberValue = 3500;
}
)
这篇关于从NSArray中检索NSDictionary,其中字典键的值为X.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文