Technology

Objective-C中获取时间间隔的方法

本文介绍如何在Objective-C中获取时间间隔,通过简单的示例代码展示了NSDate与NSTimeInterval的应用。

Sangrak
NSDate *start = [NSDate date];
//.
//. (您的代码)
//.
NSTimeInterval timeInterval = [start timeIntervalSinceNow];
NSLog([NSString stringWithFormat:"%@%f 秒\r\n", output.text, timeInterval * -1]);

更多相关内容