I’m running two async methods (see this SO thread for reference).
It’s working perfect except when I have this scenario. When an error occurs in either of the methods I will display this information for the user so in the block I will check for error and do this:
if(error) {
int64_t delayInSeconds = 2.0;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
dispatch_after(popTime, dispatch_get_main_queue(), {
// Show a popup for 2.0 seconds alerting the user of the error
});
}
This works without issue. But the issue occurs when both these async operations have errors. The first method that finishes will show the error for maybe just 0.5 seconds, and then the second async operation will show it’s error for 2.0 seconds (not taking in consideration that there is already an error message being showed).
So I need some process to check if there is already an error message being showed, then wait for that error message to go away (2.0 seconds) and then immediately show the second error message.
It sounds like you just need to implement a queue for displaying these errors to the user. You could do it as a category on
SSHUDView, with a simple interface like this:Implement it by using a serial GCD queue: