gpt4 book ai didi

iphone - NSArray 为空,filteredArrayUsingPredicate ios

转载 作者:行者123 更新时间:2023-11-28 23:10:56 25 4
gpt4 key购买 nike

我对“谓词”有一点疑问

我有 NSArray (datesArray) 组成:

(
"2011-11-30",
"2011-11-28",
"2011-11-25"
)

和另一个 NSArray (leadsArray) 组成:

(
{
"date_deadline" = "2011-11-30";
name = "test1";
};
{
"date_deadline" = "2011-11-28";
name = "test2";
};
{
"date_deadline" = "2011-11-25";
name = "test3";
};
{
"date_deadline" = "2011-11-28";
name = "test4";
};
)

然后我这样做:

NSString *date = [datesArray objectAtIndex:section];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"date beginswith %@", date];
NSArray *leads = [leadsArray filteredArrayUsingPredicate:predicate];

return [leads count];

但是我的 NSAraay(引线)是空的。

我这样做是为了了解“numberOfRowsInSection”。

你能帮帮我吗?

最佳答案

由于字典中日期的关键字是“date_deadline”,因此它至少应该读作

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"date_deadline beginswith %@", date];

在任何情况下,请考虑您是否需要 beginswith 或是否可以测试是否相等,以及您是否需要存储日期字符串或是否可以使用 NSDate 对象。

关于iphone - NSArray 为空,filteredArrayUsingPredicate ios,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8297345/

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