异步加载加载web网页

dispatch_queue_t queue = dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0
);
   
dispatch_async
(queue, ^{
       
NSURLRequest *request =[ NSURLRequest requestWithURL:[ NSURL URLWithString: @" http:// "
]];
        [
_webView loadRequest
:request];
       
NSLog( @" 使用异步函数执行主队列中的任务 1--%@",[ NSThread currentThread
]);
       
dispatch_async( dispatch_get_main_queue
(), ^{
            [
self. view addSubview: _webView
];
           
NSLog( @" 使用异步函数执行主队列中的任务 2--%@",[ NSThread currentThread
]);
        });
    });

你可能感兴趣的:(iOS基础基础进阶那些事)