Sep 12, 2016
: ~ 3 min read

I recently had this problem: at the start of the app there's a call to fetch some reference data, on which other calls depend, but it shouldn't hinder the app launch itself, nor anything else that doesn't depend on it. So, after several approaches, I decided to use DispatchGroups.

I'm sure this isn't perfect, and won't work for everyone, but it should serve some purpose, nonetheless. DispatchSemaphore would have also worked, and so would have subclassing NSOperationQueue, but I found this shorter and easier to abstract. One could improve this by passing a custom timeout and a custom DispatchQoS, for example.