Created
January 10, 2014 11:47
-
-
Save andrei512/8350635 to your computer and use it in GitHub Desktop.
hack for preventing multiple method calls in the same time. For example if you have a bug in your code that calls viewWillAppear: two times every time you can just copy/paste this code
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
// Invalidate a call if it's been less that 1 second since the last one | |
//===================================================================== | |
static NSDate *lastDate = nil; | |
NSDate *currentDate = [NSDate date]; | |
if (lastDate != nil && | |
[currentDate timeIntervalSinceDate:lastDate] < 1) { | |
return ; | |
} | |
lastDate = currentDate; | |
//===================================================================== |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment