谓词中的 HKQueryOptions
HKQueryOptions in predicate
我正在尝试使用谓词从 HealthKit 获取过去 30 天的数据。许多在线教程使用 .None
作为他们的 HKQueryOption
,并且由于我不熟悉 HKQueryOptions,我想知道是否还有其他人知道在这种情况下可以用什么替换 .None
。目前,我将 .None
作为 HKQueryOptions
放入,但这会导致我的错误。
'None' is unavailable: use [] to construct an empty option set
当我输入 []
并打印 results
时,它返回为 []
这是我声明谓词的查询函数
let sampleType = HKSampleType.quantityType(forIdentifier: HKQuantityTypeIdentifier.bloodGlucose)
let mostRecentPredicate = HKQuery.predicateForSamples(withStart: startDate, end: endDate, options:.None)
let query = HKSampleQuery(sampleType: sampleType!, predicate: mostRecentPredicate, limit: 35, sortDescriptors: nil) { (query, results, error) in
尝试使用空集文字 []
而不是 .None
:
let mostRecentPredicate = HKQuery.predicateForSamples(withStart: startDate, end:endDate, options:[])
我正在尝试使用谓词从 HealthKit 获取过去 30 天的数据。许多在线教程使用 .None
作为他们的 HKQueryOption
,并且由于我不熟悉 HKQueryOptions,我想知道是否还有其他人知道在这种情况下可以用什么替换 .None
。目前,我将 .None
作为 HKQueryOptions
放入,但这会导致我的错误。
'None' is unavailable: use [] to construct an empty option set
当我输入 []
并打印 results
时,它返回为 []
这是我声明谓词的查询函数
let sampleType = HKSampleType.quantityType(forIdentifier: HKQuantityTypeIdentifier.bloodGlucose)
let mostRecentPredicate = HKQuery.predicateForSamples(withStart: startDate, end: endDate, options:.None)
let query = HKSampleQuery(sampleType: sampleType!, predicate: mostRecentPredicate, limit: 35, sortDescriptors: nil) { (query, results, error) in
尝试使用空集文字 []
而不是 .None
:
let mostRecentPredicate = HKQuery.predicateForSamples(withStart: startDate, end:endDate, options:[])