user1069500
user1069500

Reputation: 23

NSArray empty with filteredArrayUsingPredicate ios

i have a little problem with "predicate"

i have NSArray (datesArray) which is composed to :

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

and another NSArray (leadsArray) which composed to :

(
{
    "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";
};
)

then i do that :

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

return [leads count];

But my NSAraay (leads) is empty.

I do that to know the "numberOfRowsInSection".

Can you help me please?

Upvotes: 0

Views: 1248

Answers (1)

Dennis Bliefernicht
Dennis Bliefernicht

Reputation: 5157

As the key for the dates in your dictionary is "date_deadline" it should at least read

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

In any case consider if you needs beginswith or can test for equal and if you need to store strings for dates or can use NSDate objects.

Upvotes: 2

Related Questions