Home What is the best way to difference the type of a source from HKSource in objective c?
Reply: 0

What is the best way to difference the type of a source from HKSource in objective c?

user3745888
1#
user3745888 Published in 2017-11-14 22:10:41Z

I'm reading the sources from healthkit. I want get apps, iphone, apple watch..

I have this function:

- (void)fetchSourcess{
NSMutableArray *dataSources = [[NSMutableArray alloc] init];
HKQuantityType *stepsCount = [HKQuantityType quantityTypeForIdentifier:HKQuantityTypeIdentifierStepCount];
HKSourceQuery *sourceQuery = [[HKSourceQuery alloc] initWithSampleType:stepsCount
                                                       samplePredicate:nil
                                                     completionHandler:^(HKSourceQuery *query, NSSet *sources, NSError *error){
                                  for (HKSource *source in sources){
                                      [dataSources addObject:source];
                                  }
                              }];
[self.healthStore executeQuery:sourceQuery];
}

With this function I get all sources, and with:

source.name

I can get the name, but there is any way to get the difference to know what source is an application and what is the device?

I'm thinking do a function to compare with an Equals the string if contains com. or not, but.. What could be the best way?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.305337 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO