Created
November 9, 2012 12:26
-
-
Save AlexRezit/4045445 to your computer and use it in GitHub Desktop.
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
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