我从我的目标c应用程序中读取我iPhone的健康值。 我只需要阅读最近10天,但我无法做一个查询来做到这一点。如何从healthkit获得最近10天的时间?
我试图用这个代码添加到谓词查询:
NSPredicate *explicitforDay =
[NSPredicate predicateWithFormat:@"%K >= %@ AND %K <= %@",
HKPredicateKeyPathDateComponents, startDateComponents,
HKPredicateKeyPathDateComponents, endDateComponents];
然后我尝试这样做:
NSPredicate *explicitforDay = [NSPredicate predicateWithFormat:[NSString stringWithFormat:@"%@ < %%@ AND %@ >= %%@", HKPredicateKeyPathStartDate
, HKPredicateKeyPathEndDate], myFirstDate, myEndDate];
但在输出我可以看到一些这样的:
(的startDate < CAST(529279732.871222 “的NSDate”)日期和结束日期> = CAST(527983732.871222 “的NSDate”) )
为什么打印CAST和错误的日期值? 谢谢!
我在代码中看不到任何打印命令,也没有看到日期的实际值。因此很难说,打印输出是否正确。 –