Compare HKSample with another HKSample to prevent duplication

[Swift 3.0]

I am trying to extract HKSample

from HealthKit

in order to add data to my application and would also like to update the application whenever HealthKit.

I added HKObserverQuery

and it works. However, it does not check if it exists HKSample

in my application before adding it and continually adds the sample to my application.

How to check if it exists HKSample

with identical properties?

+3


source to share


1 answer


HKSample

inherited from HKObject

.

All instances HKObject

have a property uuid

(in Swift) to uniquely identify this object.



So, when you ask, you will need to compare what you already have with the new one uuid

. Any you won't find in what you already have.

The docs are here .

+1


source







All Articles