当你想做一些 Webservicecall 或一些你调度异步调用的事情时,如下所示:
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0),^{
//Call your webservice here , your app will not freeze at all
});
现在,假设你想从你的调度线程更新或推送一个 ViewController,如果你直接从这个推送视图控制器,应用程序将会或可能会崩溃,因为这样的 UI 更新应该在应用程序的主线程中完成,下面是这个的答案然后。
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0),^{
//Call your webservice here , your app will not freeze at all
//To update UIFrom dispatched Thread:
dispatch_async(dispatch_get_main_queue,^{
//Push view controller here
});
});
详情请访问:blackberrymastercracks.blogspot.in