title: HealthKit cannot read steps data
body: <p>I'm working with HealthKit to read steps data from my iOS device.</p>
  
  <p>here is my code:</p>
  
  <pre><code>if ([HKHealthStore isHealthDataAvailable]) {
          __block double stepsCount = 0.0;
          self.healthStore = [[HKHealthStore alloc] init];
          NSSet *stepsType =[NSSet setWithObject:[HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierStepCount]];
          [self.healthStore requestAuthorizationToShareTypes:nil readTypes:stepsType completion:^(BOOL success, NSError * _Nullable error) {
              if (success) {
                  HKSampleType *sampleType = [HKSampleType quantityTypeForIdentifier:HKQuantityTypeIdentifierStepCount];
                  HKSampleQuery *sampleQuery = [[HKSampleQuery alloc] initWithSampleType:sampleType predicate:nil limit:HKObjectQueryNoLimit sortDescriptors:nil resultsHandler:^(HKSampleQuery *query, NSArray *results, NSError *error) {
                      if (error != nil) {
                          NSLog(@"results: %lu", (unsigned long)[results count]);
                          for (HKQuantitySample *result in results) {
                              stepsCount += [result.quantity doubleValueForUnit:[HKUnit countUnit]];
                          }
                          NSLog(@"Steps Count: %f", stepsCount);
                      } else {
                          NSLog(@"error:%@", error);
                  }];
                  [self.healthStore executeQuery:sampleQuery];
                  [self.healthStore stopQuery:sampleQuery];
  
                  NSLog(@"steps:%f",stepsCount);
              }
          }];
      }
  </code></pre>
  
  <p>I build and run the code on an iPhone6 which does have steps data and in the Settings -> Privacy -> Health, the app does have been allowed to read data, but the log area only shows:</p>
  
  <pre><code>steps:0.000000
  </code></pre>
  
  <p>I put a break point on the for-loop and on the <code>NSLog(@"error:%@", error)</code>, but the app does not break.</p>
  
  <p>Anybody can help?</p>