如何从上次启动获取NSTimeInterval值 [英] How to get NSTimeInterval value from last boot

查看:57
本文介绍了如何从上次启动获取NSTimeInterval值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从上次设备启动中获取NSTimeInterval值.我找到了适合此任务的CACurrentMediaTime(),但是在我的应用中,我没有使用Core Animation,并且我认为这不是为了获得此功能而包括此框架的最佳方法.还有另一种方法可以从上次启动中获得几秒钟的时间,这是一种更优雅的方式吗?

I need to get NSTimeInterval value from last device boot. I found CACurrentMediaTime() which suits this task, but in my app I am not using Core Animation and I don't think that this is the best way to include this framework just to get this function. Is there another way to get time in seconds from last boot more elegant way?

推荐答案

自上次系统重启以来的 NSTimeInterval 值可以通过以下Foundation对象和方法直接获取:

The NSTimeInterval value since the last system restart can be acquired more directly via the following Foundation object and method:

[[NSProcessInfo processInfo] systemUptime]

这篇关于如何从上次启动获取NSTimeInterval值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆