我有一个NSArray
with NSDictionaries
。数组之一中的字典键之一包含一个值。我想找回NSDictionary
具有该值。
我的阵列:
Array: (
{
DisplayName = "level";
InternalName = "Number 2";
NumberValue = 1;
},
{
DisplayName = "PurchaseAmount";
InternalName = "Number 1";
NumberValue = 3500;
}
)
所以,我想要一本包含以下内容的词典DisplayName
set to PurchaseAmount
(不区分大小写)。
我怎样才能做到这一点?
以下解决了我的问题:
NSArray *filtered = [promotions filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"(DisplayName == %@)", @"PurchaseAmount"]];
NSDictionary *item = [filtered objectAtIndex:0];
感谢用户 Nate 对我的问题的评论!
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)