HealthObserverQuery in Health Kit

时间:2016-03-29 05:24:38

标签: ios objective-c iphone health-kit

HKObserverQuery以哪种格式获取数据? 没有NSArrayNSDictionary来存储数据然后如何获取。 我把查询放入无法获取所有数据,有人请帮忙吗?

HKObserverQuery *query =
[[HKObserverQuery alloc]
 initWithSampleType:object
 predicate:Predicate
 updateHandler:^(HKObserverQuery *query,
                 HKObserverQueryCompletionHandler completionHandler,
                 NSError *error) {
[HKUnit unitFromString:@"count/min"]];


     if (error) {

         // Perform Proper Error Handling Here...
         NSLog(@"*** An error occured while setting up the stepCount observer. %@ ***",
               error.localizedDescription);
         abort();
     }
     else{
         NSLog(@"@%",query);
         }

 }];

1 个答案:

答案 0 :(得分:1)

HKObserverQuery无意向您的应用投放数据。只要在HealthKit中添加或删除与您的谓词匹配的updateHandler,就会调用HKSample。然后由您的应用自行执行其他查询,例如HKSampleQueryHKStatisticsQuery