Skip to content

Instantly share code, notes, and snippets.

@phynet
Last active April 4, 2017 10:24
Show Gist options
  • Save phynet/122f522e305ac43e31b4 to your computer and use it in GitHub Desktop.
Save phynet/122f522e305ac43e31b4 to your computer and use it in GitHub Desktop.
NSDate *animationStart = [NSDate date];
NSTimeInterval pendingTime = MAX(2 - [[NSDate date] timeIntervalSinceDate:animationStart], 0);
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(pendingTime * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
//call a method .... do something
});
//DISPATCH_TIME_NOW is a constant declared in dispatch class from iOS 9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment