How can I get a time difference with CFAbsoluteTime in Swift?


How can I get a time difference with CFAbsoluteTime in Swift?



I'm developing a test mobile App (Single view App., iOS 11.4).



My code is under here.


override func viewDidLoad() {
// ...
let pastTime = CFAbsoluteTimeGetCurrent()

// ...
let elapsedTime = ((CFAbsoluteTimeGetCurrent - pastTime) * 10000).rounded(.down) * 0.0001
print((elapsedTime)) // I can get a time difference in sec (x.xxxx)

// I want to call under function
someFunc(floatTypeValue: elapsedTime)

// ...
}



How can I get a time difference in Float?



How can I convert or cast the "elapsedTime" constant to Float?









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

api-platform.com Unable to generate an IRI for the item of type

How to set up datasource with Spring for HikariCP?

PHP contact form sending but not receiving emails