Monday, 28 May 2012

using blocks switch to another thread and run on main thread

//   You can add hud on main thread as
//    HUD = [MBProgressHUD showHUDAddedTo:self.view.window animated:YES];

        dispatch_queue_t workerQueue = dispatch_queue_create("QueueIdentifier", NULL);
        dispatch_async(workerQueue, ^ {
           
         // do something for network or any thing which is not using UI changes
                                   
                        dispatch_sync(dispatch_get_main_queue(), ^{
                           
                          // change in UI run this code
                         // like hide HUD
                              //  [HUD removeFromSuperview];
                        });
           
        });

No comments:

Post a Comment