我想使用 Apple Watch 中的历史加速度计数据,而我的 accDataList 始终为零。我在类的 init 函数中实例化了 CMSensorRecorder。以前有人遇到过这个问题吗?
func startMovementDetection(){
self.cmSensorRecorder?.recordAccelerometerFor(self.recorderDuration)
self.startDate = NSDate()
}
func extractHistoricalAccelerometerData(){
var accDataList = self.cmSensorRecorder!.accelerometerDataFrom(self.startDate, to: NSDate())
NSLog("AccDataList : \(accDataList)")
if accDataList != nil {
accDataList = accDataList as CMSensorDataList
for accData in accDataList {
self.addHistoricalAccDataToMovementArray((accData as? CMRecordedAccelerometerData)?.acceleration)
}
self.sendDataToIphone()
}
}
日志如下所示:
2015-07-11 22:02:55.279 emmoveDataWatchOS 扩展[2158:2428612] 开始录制
2015-07-11 22:02:55.279 emmoveDataWatchOS 扩展 [2158:2428612] AW:开始运动更新
2015-07-11 22:02:55.279 emmoveDataWatchOS 扩展 [2158:2428612] AW EMWatchManager: startMovementDetection
2015-07-11 22:02:55.279 emmoveDataWatchOS 扩展[2158:2428612] 可选(CMSensorRecorder:0x797733d0)
2015-07-11 22:10:51.483 emmoveDataWatchOS 扩展 [2158:2428612] AW:定格动画更新
2015-07-11 22:10:51.484 emmoveDataWatchOS Extension[2158:2428612] 从 Optional(2015-07-11 20:02:55 +0000) 到 2015-07-11 20:10:51 +0000 提取数据
2015-07-11 22:10:51.484 emmoveDataWatchOS 扩展 [2158:2428612] 可选(CMSensorRecorder:0x797733d0)
2015-07-11 22:10:51.486 emmoveDataWatchOS 扩展[2158:2428612] AccDataList:无