Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
public extension Int {
public var seconds: DispatchTimeInterval {
return DispatchTimeInterval.seconds(self)
}
public var second: DispatchTimeInterval {
return seconds
}
public var milliseconds: DispatchTimeInterval {
return DispatchTimeInterval.milliseconds(self)
}
public var millisecond: DispatchTimeInterval {
return milliseconds
}
}
public extension DispatchTimeInterval {
public var fromNow: DispatchTime {
return DispatchTime.now() + self
}
}
// Example:
DispatchQueue.main.asyncAfter(deadline: 3.seconds.fromNow) {
// do something
}
// Instead of:
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + DispatchTimeInterval.seconds(3)) {
// do something
}
@jbarros35
Copy link

jbarros35 commented Jul 20, 2018

its pretty useful thanks

@Stebulis
Copy link

Stebulis commented Nov 28, 2018

Very useful indeed

@denniskeithgaso
Copy link

denniskeithgaso commented Dec 4, 2018

Very useful. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment