使用ios健康工具包获取swimStrokesCount

时间:2017-07-06 18:02:13

标签: ios watchkit health-kit hkhealthstore

我试图从健康套件中获取游泳次数。我开始锻炼游泳类型,然后尝试使用代码访问游泳中风:

        let swimmingStrokesCountQuery = HKAnchoredObjectQuery(type: swimmingStrokeCountType!, predicate: nil, anchor: nil, limit: Int(HKObjectQueryNoLimit), resultsHandler: { (query, sampleObjects, deletedObjects, newAnchor, error) in
        self.updateStrokes(samples: sampleObjects)
    })

    swimmingStrokesCountQuery.updateHandler = {(query, samples, deleteObjects, newAnchor, error) in
        self.updateStrokes(samples: samples)
    }

    healthStore.execute(swimmingStrokesCountQuery)

但我没有得到任何样品。当我尝试运行锻炼类型的步骤时,它使用类似的代码。是否有可能获得swimStrokeCount或者只是不提供它而且我应该自己实施中风计数?感谢

0 个答案:

没有答案