Используйте .separateBySource
в настройках вашего запроса. Например:
guard let sampleType = HKObjectType.quantityType(forIdentifier: .stepCount)
else {
fatalError("Couldn't create the quantityType for .stepCount")
}
let calendar = Calendar.current
var dateComponents = DateComponents()
dateComponents.day = 1
var anchorComponents = calendar.dateComponents([.day, .month, .year], from: Date())
anchorComponents.hour = 0
guard let anchorDate = calendar.date(from: anchorComponents) else {
fatalError("Couldn't get the anchor date")
}
let stepsCumulativeQuery =
HKStatisticsCollectionQuery(quantityType: sampleType,
quantitySamplePredicate: nil,
options: [.cumulativeSum , .separateBySource],
anchorDate: anchorDate,
intervalComponents: dateComponents)