首页 > 代码库 > healthKit的一些知识点
healthKit的一些知识点
healthKit的一些知识点
by 伍雪颖
HealthKit HKUnit HKUnit *g = [HKUnit gramUnit]; HKUnit *dL = [HKUnit literUnitWithMetricPrefix:HKMetricPrefixDeci]; HKUnit *gPerdL = [g unitDividedByUnit:dL]; HKQuantity HKUnit *gramUnit = [HKUnit gramUnit]; HKQuantity *grams = [HKQuantity quantityWithUnit:gramUnit doubleValue:20]; double kg = [grams doubleValueForUnit:[HKUnit unitFromString:@"kg"]]; BOOL kgCompatible = [grams isCompatibleWithUnit:[HKUnit unitFromString:@"kg"]]; BOOL kCalCompatible = [grams isCompatibleWithUnit:[HKUnit kilocalorieUnit]]; HKObject NSString *identifier = HKQuantityTypeIdentifierBodyTemperature; HKQuantityType *tempType = [HKQuantity quantityWithUnit:[HKUnit degreeFahrenheitUnit] doubleValue:98.6]; NSDictionary *meta = @{HKMetadataKeyBodyTemperatureSensoLocation: @(HKBodyTemperatureSensorLocationEar)}; HKQuantitySample *temperatureSample = [HKQuantitySample QuantitySampleWithType:tempType quantity:myTemp startDate:[NSDate date] endDate:[NSDate date] metadata:meta]; HKHealthStore self.store = [[HKHealthStore alloc] init]; HKQuantitySample *mySample = [self newSample]; [self.store saveObject:mySample withCompletion:^(BOOL success,NSError *error) { if (success) { } }]; HKQuery --- Predicates HKQuantity *weight = [NSPredicate predicateWithFormat:@"%K > %@", HKPredicateKeyPathQuantity,weight]; HKAnchoredObjectQuery self.lastAnchor = 0; HKAnchoredObjectQuery *query; query = [[HKAnchoredObjectQuery alloc] initWithType:bloodSugar Predicate:nil anchor:self.lastAnchor limit:HKObjectQueryNoLimit CompletionHandler:^(HKAnchoredObjectQuery *query, NSArray *results, NSUInteger newAnchor, NSError *error) { self.lastAnchor = newAnchor; NSLog(@"Results:%@",results); }];
healthKit的一些知识点
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。