Created
February 28, 2017 19:51
-
-
Save nickjacob/fac51b5daa485829d1cf4ccd17592df3 to your computer and use it in GitHub Desktop.
Convert dispatch_time_t to NSNumber (ms)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Convert a dispatch_time_t to milliseconds. | |
* note that this only works if dispatch time is in the future, | |
* and is approximate (since the time now will be slightly different than | |
* the time you made the dispatch_time_t). | |
*/ | |
static NSNumber * dispatch_future_to_ms(dispatch_time_t time) { | |
uint64_t abs = mach_absolute_time(); | |
return @((time - abs) / NSEC_PER_MSEC); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment