我從我的目標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和錯誤的日期值? 謝謝!
我在代碼中看不到任何打印命令,也沒有看到日期的實際值。因此很難說,打印輸出是否正確。 –