Skip to content

Instantly share code, notes, and snippets.

@AlexRezit
Created November 9, 2012 12:26
Show Gist options
  • Save AlexRezit/4045445 to your computer and use it in GitHub Desktop.
Save AlexRezit/4045445 to your computer and use it in GitHub Desktop.
static NSOperationQueue *__updateUIQueue;
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
if (!__updateUIQueue) {
__updateUIQueue = [[NSOperationQueue alloc] init];
}
[__updateUIQueue addOperationWithBlock:^{
while (TRUE) {
dispatch_async(dispatch_get_main_queue(), ^{
[self updateUI];
});
sleep(1);
}
}];
}
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
[__updateUIQueue cancelAllOperations];
__updateUIQueue = nil;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment