tags:

views:

219

answers:

1

I am trying to filter my table with only relevant records by date range.

NSPredicate *currentDaypredicate =
    [NSPredicate predicateWithFormat: @"account.entries.dateCreated > %@ AND
        account.entries.dateCreated < %@ ", yesterday, tomorrow];
[accountArrayController setFilterPredicate:currentDaypredicate];

But of course this is wrong because I'm getting-

[NSCFSet compare:]: unrecognized selector sent to instance

Can someone please give me a clue or example?

+2  A: 

As the exception message says, you can't compare two sets, and account.entries.dateCreated is a set. This is most probably because account.entries is a set; sending a valueForKey: message to a set will return a set.

You need to test each date, not all of the dates at once. Try ANY account.entries.dateCreated > %@ AND ANY account.entries.dateCreated < %@.

(By the way, why are the objects that have accounts in an “accountArrayController”? Shouldn't the accounts themselves be there?)

For more on predicate format string syntax, see that section of the Predicate Programming Guide.

Peter Hosey
Thanks, using "@distinctUnionOfSets" and with the "ANY" solved my problem.
Seymour Cakes