gpt4 book ai didi

objective-c - NSPredicate 不适用于字典数组

转载 作者:太空狗 更新时间:2023-10-30 03:59:08 27 4
gpt4 key购买 nike

我有一个格式如下的 NSPredication:@"Status CONTAINS[cd] shipped"

我有一个字典数组,下面是一个例子:

{
{
Category = "Category 4";
Comp = "Category 4";
Depth = 02;
Grade = New;
Length = 02;
Location = "Thousand Oaks, CA";
Name = "3ply Mat";
Owner = "Owner 3";
PUP = 2;
Status = Shipped;
"Unit Number" = 20110507113852351;
Width = 02;
},
{
Category = "Category 4";
Comp = "Category 4";
Depth = 02;
Grade = New;
Length = 02;
Location = "Thousand Oaks, CA";
Name = "3ply Mat";
Owner = "Owner 3";
PUP = 2;
Status = Shipped;
"Unit Number" = 20110516094641587;
Width = 02;
}
)

但它返回一个空数组。我究竟做错了什么?谢谢

最佳答案

你想要:

[NSPredicate predicateWithFormat:@"Status =[cd] 'shipped'"];

或者:

[NSPredicate predicateWithFormat:@"Status =[cd] %@", @"shipped"];

你的问题是你的谓词格式已经shipped,而它应该已经'shipped'。缺少单引号意味着它试图将 [dictionary valueForKey:@"Status"][dictionary valueForKey:@"shipped"] 进行比较,而不是与字符串进行比较文字 @"shipped".

关于objective-c - NSPredicate 不适用于字典数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6185008/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com