views:

214

answers:

1

I'm using the Fetch Predicate in the IB to filter our the default result return from Core Data and I'm actually looking for some like this:

dateCreated < YESTERDAY

where "YESTERDAY" is supposed to be a nsdate constant for yesterday so that all my result return is before yesterday.

This didn't work. And some searching didn't turn up anything related to this so I'm wondering what I want to do here is possible.

+2  A: 

Irrespective of Core Data (because this really has nothing to do with Core Data, only predicates), your query itself (before a certain date) is perfectly normal, but the predicate syntax has no facilities for "natural language" dates.

You pass in a date object and that's that. It's up to you to create an appropriate date object to represent "yesterday".

To get the same sort of "automatic" behavior you're looking for, you could bind your array controller's fetch predicate to some controller via some key (KVC-compliant method) like "beforeYesterdayPredicate" ... this method would hand back a dynamically-generated predicate that you'd create with code.

Joshua Nozzi