【发布时间】:2018-03-21 05:11:04
【问题描述】:
我正在从我的目标 c 应用程序中读取我的 iPhone 的健康值。 我只需要阅读过去 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(527983732.871222, "NSDate"))
为什么要打印 CAST 和错误的日期值? 谢谢!
【问题讨论】:
-
我在您的代码中既没有看到任何打印命令,也没有看到日期的实际值。因此很难说打印出来的是否正确。
标签: ios objective-c nsdate nspredicate healthkit