UIKit Dynamics - Replacing Animations | raywenderlich.com


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/9238-uikit-dynamics-replacing-animations

What does NSEC_PER_SEC means? and why are you using it in
let delayTime = DispatchTime.now() + Double(Int64(0.75 * Double(NSEC_PER_SEC)))/Double(NSEC_PER_SEC)?
Wouldn’t we achieve the same with: let delayTime = DispatchTime.now() + 0.75

Thanks

@hococoder Can you please help with this when you get a chance? Thank you - much appreciated! :]

That’s a great catch! It is much simpler in Swift 4, and that’s something I missed while getting the code ready. You can now do

let delayTime = .now() + 0.75

since there is a built in override of “+” operator that takes in a DispatchTime on one side and a double on the other.

You can also be specific with milliseconds or nanoseconds:

let delayTime = .now() + .milliseconds(500)

let delayTime2 = .now() + .nanoseconds(999)

Thanks for watching the screencast, and thanks for the question!