Skip to content

Instantly share code, notes, and snippets.

@petermolnar-dev
Last active January 22, 2021 13:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save petermolnar-dev/aa575980a86404cc48216cc3398da87e to your computer and use it in GitHub Desktop.
Save petermolnar-dev/aa575980a86404cc48216cc3398da87e to your computer and use it in GitHub Desktop.
typealias HKSamplesResult = Result<[HKSample], Error>
func fetchAllBloodPressure(completion: @escaping (HKSamplesResult) -> ()) {
let correlationType = HKCorrelationType.correlationType(forIdentifier: .bloodPressure)!
let query = HKCorrelationQuery(type: correlationType, predicate: nil, samplePredicates: nil) {
(query, results, error) in
guard let correlations = results, error == nil else {
print("Error during the query: \(String(describing: error?.localizedDescription))")
completion(.failure(HKStoreManagerError.QueryExecutionError))
return
}
completion(.success(correlations))
}
healthStore.execute(query)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment