I'm reading health values of my iPhone from my objective c app. I need only read the last 10 days, but I can't do a query to do this.
I'm trying add into a predicate the query with this code:
NSPredicate *explicitforDay =
[NSPredicate predicateWithFormat:@"%K >= %@ AND %K <= %@",
HKPredicateKeyPathDateComponents, startDateComponents,
HKPredicateKeyPathDateComponents, endDateComponents];
And then I tried this:
NSPredicate *explicitforDay = [NSPredicate predicateWithFormat:[NSString stringWithFormat:@"%@ < %%@ AND %@ >= %%@", HKPredicateKeyPathStartDate
, HKPredicateKeyPathEndDate], myFirstDate, myEndDate];
But in output I can see some like this:
(startDate < CAST(529279732.871222, "NSDate") AND endDate >= CAST(527983732.871222, "NSDate"))
Why are printing a CAST and wrong date values? Thanks!