Created
May 10, 2011 06:16
-
-
Save chrishulbert/963992 to your computer and use it in GitHub Desktop.
Revisions
-
chrishulbert created this gist
May 10, 2011 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ // Using grand central dispatch (GCD) so we don't block the GUI dispatch_async(dispatch_get_global_queue(0, 0), ^{ // Background, long stuff runs here, but doesn't affect the GUI dispatch_async(dispatch_get_main_queue(), ^{ // The GUI thread stuff goes here [self.tableView reloadData]; // example }); }); // Just like javascript's setTimeout: call a block after a delay, on the main thread: dispatch_time_t delay = dispatch_time(DISPATCH_TIME_NOW, NSEC_PER_SEC * 0.5); // Make it happen in half a second dispatch_after(delay, dispatch_get_main_queue(), ^(void){ // This will happen after the delay });