Skip to content

Instantly share code, notes, and snippets.

@andrei512
Created January 10, 2014 11:47
Show Gist options
  • Save andrei512/8350635 to your computer and use it in GitHub Desktop.
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
// 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