简体   繁体   English

在iOS中,使用Swift,如何获取iPhone开机的时间?

[英]In iOS, using Swift, how do you get the time of iPhone boot?

In core motion, data is returned in a class inheriting from CMLogItem , which has a timestamp property.在核心运动中,数据在继承自CMLogItem的类中返回,该类具有timestamp属性。 The timestamp is a TimeInterval that is the time since the device booted. timestamp是一个TimeInterval ,它是自设备启动以来的时间。

How do I get when the device booted?设备启动时如何获取?

From the comments, I was able to find ProcessInfo.processInfo.systemUptime which is the time since last boot.从评论中,我能够找到ProcessInfo.processInfo.systemUptime这是自上次启动以来的时间。 From this, and Date() , I can get the time of start via:从此和Date() ,我可以通过以下方式获得开始时间:

time_of_last_boot = Date() - ProcessInfo.processInfo.systemUptime

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在swift iOS for iPhone中使用FBSDK获取用户电子邮件地址? - How to get user email address using FBSDK in swift iOS for iPhone? IOS - 如何在 swift 中获取当前滚动视图 position? - IOS - How do you get current scrollview position in swift? 你如何使用coreLocation读取完整地址(iOS / Swift) - How do you read FULL address using coreLocation ( iOS/ Swift ) 如何在Swift中为iOS UIElement设置样式? - How do you style iOS UIElements in Swift? 如何在iOS 8和iPhone 6上获取经纬度坐标? - How do you get latitude and longitude co-ordinates on iOS 8 and iPhone 6? 如何获取当前 EST 时间 IOS Swift - How to get Current EST time IOS Swift 如何在iOS 8+中以编程方式配置和呈现iPhone上的弹出窗口 - How do you programmatically configure and present a popover on iPhone in iOS 8+ 如何使用 Swift/MacOS 或 iOS 和 Core Image 将 Core Image 滤镜应用于屏幕图像 - How do you apply Core Image filters to an onscreen image using Swift/MacOS or iOS and Core Image 如何使用 Swift 将数据从 IOS 应用程序发布到 MySQL 表? - How do you POST data from an IOS app to MySQL table using Swift? 如何使用Swift工具将Game Center集成到Xcode 6中的带有恶意工具包的iOS应用程序中? - How do you integrate Game Center into a iOS Application in Xcode 6 with spite kit using the language Swift?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM