搜尋

首頁  >  問答  >  主體

objective-c - 實現的計步器所獲得的資料與健康APP中的資料不一致,求解。

在呼叫CoreMation框架取得計步資料的時候, 我想取得某一段時間內 每天的計步數的情況。我取得到的數據 和 健康APP中的數據不一樣,請問我這個地方是不是設定的時間不對?我該怎麼設定呢?

下面是我的程式碼和 輸出日誌:

//加载最新数据
- ( void)loadLastestDatas
{
    for (int i = 1; i < 10; i++)
    {
        NSString *dateStr = [NSString stringWithFormat:@"2016-09-0%zd", i];
    
        NSDate *fromDate = [NSDate date];
        fromDate = [DateUtil stringToDate:dateStr dateFormat:@"yyyy-MM-dd"];
    
        NSLog(@"from:%@", fromDate);
        [self addStepsDataWithDate:fromDate];
    }
    [self endRefresh];
    [self.tableView reloadData];
}

- (void)addStepsDataWithDate:(NSDate *)fromDate
{
    WS(ws);
    [self.pedometer queryPedometerDataFromDate:fromDate
                                        toDate:[NSDate dateWithTimeInterval:24*60*60 sinceDate:fromDate]//后一天
                                   withHandler:^(CMPedometerData * _Nullable pedometerData, NSError * _Nullable error) {
        
        [[NSOperationQueue mainQueue] addOperationWithBlock:^{
            if (pedometerData == nil) {
                return;
            }
            NSString *str = [NSString stringWithFormat:@"共走了%@步", pedometerData.numberOfSteps];
            [ws.datas addObject:str];
        }];
    }];

    
}

2016-09-10 10:40:00.344 GYBase[4342:2163762] from:2016-09-01 00:00:00 +0000
2016-09-10 10:00 +00.33:002016-09-10 10:40:0063:00:0063:0007:006: 2016-09-02 00:00:00 +0000
2016-09-10 10:40:00.355 GYBase[4342:2163762] from:2016-09-03 00:00:001001010 +0020101010101010102010101020102010102010201020101 :40:00.357 GYBase[4342:2163762] from:2016-09-04 00:00:00 +0000
2016-09-10 10:40:00.359 GYBase[4342:016362:40:00.359 GYBase[4342:5163620:00:00:00:00:50 00:00 +0000
2016-09-10 10:40:00.361 GYBase[4342:2163762] from:2016-09-06 00:00:00 +0000
2016-060310:40:4020:400:40009:40099: :2163762] from:2016-09-07 00:00:00 +0000
2016-09-10 10:40:00.364 GYBase[4342:2163762] from:2016-09-008800 -09-10 10:40:00.366 GYBase[4342:2163762] from:2016-09-09 00:00:00 +0000
2016-09-10 10:40:00.377 GYBase2016-09-10 10:40:00.377 GYBase[632216321621632121632121632216323:00:006212162216232123:036]:步
2016-09-10 10:40:00.379 GYBase[4342:2163762] 共走了8618步
2016-09-10 10:40:00.380 GYBase[4342:09-10 10:40:00.380 GYBase[4342:163762016376200YBase[4342:1637620163762030 10 10:40:00.380 GYBase[4342:2163762] 共走了9596步
2016-09-10 10:40:00.381 GYBase[4342:2163762] 共走了7410883:010862] 共走了1010883:0108 GYBase[4342:2163762] 共走了7213步
2016-09-10 10:40:00.382 GYBase[4342:2163762] 共走了7821步
2016-09-10 10:40:00.383 GYBase[4342:2163762]共走了7389步
2016-09-10 10:40:00.383 GYBase[4342:2163762] 共走了7461步

请输入代码

下面是我健康APP中的資料


滿天的星座滿天的星座2753 天前788

全部回覆(0)我來回復

無回覆
  • 取消回覆