I saw a lot of topics about it and still unclear ..
1)
When I doing :
dispatch_async(dispatch_get_main_queue(), ^(void) {
for(int i = 0; i < 10000000; i++)
{
NSLog(@" i = %i", i);
}
});
The UI is froze, I can't click in any button. If I understand, it's because it's called on dispatch_get_main_queue, that's say the main thread ? So why talking about "background" if the UI is froze ?
2)
dispatch_async(dispatch_get_main_queue(), {
self.tableData = results
self.appsTableView!.reloadData()
})
})
The context : I get back some data (session.dataTaskWithURL ) from an api service and when I received all informations, I'm doing this dispatch.
But I didn't understood the explanations, I quote :
"Because this task happens in the background, we need to jump in to the foreground before we update the UI. So we need to use dispatch_async to move back in to the main thread, and reload the table view."
Hum ?? It is because the session url was in background and now it's necessary to come back to the main thread ? And what if we don't come back ?
3) I listened something like updating the UI from another thread is not safe. Why ?
4) A little HS, but will be nice : Now, I'm waiting that the request finish to receive all informations and display it to the UI. It can be 3 secondes for exemple. During this laps of tame, the UI is empty. It is possible to display informations in the UI little by little the data are received and not waiting that the request finish ?
Thanks a lot in advance, all !