Skip to content

Instantly share code, notes, and snippets.

@kevinvanderlugt
Created September 6, 2014 01:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevinvanderlugt/c4b533f9fc054893da3c to your computer and use it in GitHub Desktop.
Save kevinvanderlugt/c4b533f9fc054893da3c to your computer and use it in GitHub Desktop.
// Replace
[self.gameTimer invalidate];
self.gameTimer = nil;
// With
dispatch_async(dispatch_get_main_queue(), ^{
[self.gameTimer invalidate];
self.gameTimer = nil;
});
// Replace
self.startTime = [NSDate timeIntervalSinceReferenceDate];
self.gameTimer = [NSTimer scheduledTimerWithTimeInterval:0.005
target:self
selector:@selector(gameTimerFired)
userInfo:nil
repeats:YES];
// With
dispatch_async(dispatch_get_main_queue(), ^{
self.startTime = [NSDate timeIntervalSinceReferenceDate];
self.gameTimer = [NSTimer scheduledTimerWithTimeInterval:0.005
target:self
selector:@selector(gameTimerFired)
userInfo:nil
repeats:YES];
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment