Skip to content

Instantly share code, notes, and snippets.

@chuckntaylor
Last active June 14, 2019 16:00
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
Swift utility functions
// Degrees to Radians
func degreesToRadians(_ number: Double) -> Double {
return number * .pi / 180
}
// Radians to Degrees
func radiansToDegrees(_ number: Double) -> Double {
return number / Double.pi * 180
}
// Delay function with closure
func delay(seconds: Double, completion: @escaping ()-> Void) {
DispatchQueue.main.asyncAfter(deadline: .now() + seconds, execute: completion)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment