在Objective-C中花费时间 [英] Getting time elapsed in Objective-C
本文介绍了在Objective-C中花费时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要在两个事件之间花费时间,例如,UIView的出现和用户的第一反应。
I need to get the time elapsed between two events, for example, the appearance of a UIView and the user's first reaction.
如何在Objective中实现它-C?
How can I achieve it in Objective-C?
推荐答案
NSDate *start = [NSDate date];
// do stuff...
NSTimeInterval timeInterval = [start timeIntervalSinceNow];
timeInterval
是start和now之间的区别,以秒为单位,精确度为亚毫秒。
timeInterval
is the difference between start and now, in seconds, with sub-millisecond precision.
这篇关于在Objective-C中花费时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文