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 What am I asking, if the group is adding samples or data to the hours. In SQL, I will write something like this: 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 You should use the You can 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 .
SELECT HOUR (date), healthcare from SUM (steps) where 'bla' and 'blah' group by 1;
resultHandler is implemented.
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
Comments
Post a Comment