检索HKSampleQuery范围之外的变量的值

时间:2017-06-01 13:32:01

标签: ios swift health-kit hksamplequery

我正在从sleepAnalysis检索HealthKit数据,并希望将这些样本存储在全局数组中,但一旦我超出HKSampleQuery的范围,{ {1}}回到它的空数组的初始值。如何在查询范围之外检索这些值?

self.globalVariable

if let sleepType = HKObjectType.categoryType(forIdentifier: HKCategoryTypeIdentifier.sleepAnalysis) { let sortDescriptor = NSSortDescriptor(key: HKSampleSortIdentifierEndDate, ascending: false) let query = HKSampleQuery(sampleType: sleepType, predicate: nil,limit: 90, sortDescriptors: [sortDescriptor]) { (query, tmpResult, error)-> Void in if error != nil { return } if let result = tmpResult { for item in result { if let sample = item as? HKCategorySample { samples.append(sample) } } } healthStore.execute(query) } } 范围之外,样本为零。

0 个答案:

没有答案