#pragma mark - 获取步数从HealthKit - (void)getstepCountFromHealthKit { HKQuantityType *type = self.items[5]; //这个函数是获取苹果健康里面的全部步数包括人为添加的 [self fetchQuantity:typecompletionHandler:^(NSArray *result,NSError *error) { dispatch_async(dispatch_get_main_queue(), ^{ if (error) { //从苹果健康获取步数失败 NSLog(@"error:%@",error); [PersonInfo sharePersonInfo].isAllow = NO; } else if ([resultcount] == 0) { //没有步数 [PersonInfo sharePersonInfo].isAllow = YES; } // succeeded to retrieve the health data else { [PersonInfo sharePersonInfo].isAllow = YES; //这个函数是去除人为添加的,留下系统记录的步数 NSArray *array = [selfgetRealHealthData:result]; //统计数组里面的步数 NSInteger allArrStepCount = 0; //一个数组的添加 for (NSDictionary *dictin array) { NSInteger stepCount = [dict[@"stepCount"]integerValue]; allArrStepCount = allArrStepCount + stepCount; NSString *dateTime = dict[@"dateTime"]; [_dateTimeArr addObject:dateTime];