iphone - nslog时间戳

标签 iphone timestamp nslog

我想记录设备运动时间戳属性。

设备运动位于 CMMotionManager.devicemotion.timestamp 类中

任何想法。

最佳答案

这是我提出的解决方案,因为日期是根据 Apple 文档得出的:

The time stamp is the amount of time in seconds since the phone booted.

我首先在第一次测量时保存 originDate (如果我的 NSDate 为零)。

[self.motionManager startGyroUpdatesToQueue:self.queue withHandler:^(CMGyroData *gyroData, NSError *error) {
    if (self.originDate == nil) {
        self.originDate = [NSDate dateWithTimeIntervalSinceNow:-gyroData.timestamp];
    }   
}];

然后我可以显示当我想要这样的真实日期:

[NSDate dateWithTimeInterval:mygyroData.timestamp sinceDate:self.originDate]

如果您需要重新启动某些测量,请不要忘记将 originDate 重置为 nil。

关于iphone - nslog时间戳,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6911226/

相关文章:

mysql - 按时间戳字段的日期部分分组

iphone - iPhone 上的 FTP 与 HTTP 上传

iphone - 无法让 Apple Reachability 类正确定义网络

iphone - UITableView,拦截Edit模式

ios - 使用 xib 设置cameraOverlayView

php - 在 php 中获取给定月份和年份的开始和结束 unix 时间戳

MySQL : Select on timestamp column, 将秒更改为 00 并将分钟向下舍入到最接近的 10

objective-c - sprintf 自发失败,具体取决于有哪些 printf 和 NSLog 调用

iphone - 使用 NSLog 打印 NSString 参数

objective-c - UTF8字符串问题