ios - How to group HKStatistics by hour? -


I'm trying to extract step data from the healthcare.

I want to summarize the phase grouped data by hour, currently, between a date range provided by NSPredicate with HKSampleQuery I can remove all the samples of the data. I could also obtain an amount of phase count between the date range with HKStatisticsQuery .

What am I asking, if the group is adding samples or data to the hours. In SQL, I will write something like this:

SELECT HOUR (date), healthcare from SUM (steps) where 'bla' and 'blah' group by 1;

Do I want to write the last month of the last one hour grouped data for HKStatistics 24x31 times queries? Because it is very inefficient, especially how resultHandler is implemented.

You should use the HKStatisticsCollectionQuery , where you are based on time intervals Group can. An example would be a stub code:

  NSDate * startDate, * endDate, * anchorDate; // Whatever you need in your case, HKQuantityType * type = [HKObjectType volume typeford identifier: HKQuantityTypeIdentifierStepCount]; // Your Interval: Hours of Yoga NSDTech.com * Interval Companents = [[NSDATCompanies Alok] Init]; IntervalComponents.hour = 1; / Example NSPredicate * predicate = for example [HKQuery predicateForSamplesWithStartDate: fromDate endDate: toDate option: HKQueryOptionStrictStartDate]; HKStatisticsCollectionQuery * query = [[HKStatisticsCollectionQuery alloc] initWithQuantityType: Type VolumeCommunity: Forecasting Options: HKStatisticsOptionCumulativeSum anchorDate: anchorDate intervalComponents: intervalComponents]; Query.initialResultsHandler = ^ (HKStatisticsCollectionQuery * Query, HKStatisticsCollection * Results, NSError * Error) {// Do something with results}; [Healthstore ExecuteQQQ: Query]; You can read more details in   

You can

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -