Scenario: The app consumes data from a web service, so that the app is not "locked" I added the task of downloading the data in a secondary trhead, according to the following code:
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
//realize aqui o trabalho em background
dispatch_async(dispatch_get_main_queue(), ^{
//quando as operações em background forem concluídas, execute aqui o código na thread principal para atualização da tela, caso necessário
});
});
However, when the web service is down, the app is waiting for the server to respond, and after a while without the response, iOS terminates my app.
I would like to know if there is a Design Pattern for this type of situation, where we can control how long the app will wait for the server to respond, and tell iOS to close the data request process without having to close the app !