Reputation: 1533
I am syncing weight data from HealthKit and I keep a reference to the latest weight data synced which I use to retrieve HealthKit data like this:
let predicate = HKQuery.predicateForSamplesWithStartDate(latestSyncDate, endDate:NSDate(), options: .None)
The problem with this approach is when the user enters historic data which will not be synced. How do I perform the same query but with CreationDate (instead of StartDate), or some kind of database ID which will identify the historic value as being newer?
I just want to filter out all the newly created values from healthkit.
Upvotes: 2
Views: 5014
Reputation: 7353
If you'd like synchronize data from HealthKit, check out HKAnchoredObjectQuery. Each time you query with HKAnchoredObjectQuery
, you'll get only the samples that have been added or deleted since the last time you queried.
Upvotes: 5