mardi 24 mars 2015

sum of results from for - in loop, in swift

I am playing around with Apples sample code for Health kit. They have put a for-in loop function to iterate through all the sample within the last 24hours. The code of course works great.


Using the for-in loop in swift, would it be possible to find the sum of all the values?


I have been trying but can not find the solution.


Thanks Chris


Here is the code:



for sample in results as [HKQuantitySample] {
let joules = sample.quantity.doubleValueForUnit(HKUnit.jouleUnit())



Aucun commentaire:

Enregistrer un commentaire