I have an entity with an attribute date which is an NSDate. How would I construct a predicate to get the earliest date stored in the model?
I want to be able to calculate the number of days between now and the earliest date in the entity you see so I can lay them out in a tableview one day at a time. This bit I’m sure I can do myself.
Thanks for all your help.
Construct an
NSExpressionto retrieve the minimumdate. Something like the following:You can then wrap this in an
NSExpressionDescription, callsetPropertiesToFetch:on your request, and execute it as normal. Instead of returning an array of managed objects, it will now return a dictionary containing the result of your expression—the minimum date.See the Fetching Specific Values section of Apple’s Core Data Programming Guide for a more detailed explanation and sample code.