I have multiple web services to be checked and downloaded in the background of my app, using NSURLSession
to do this. When the app is in the background I use this code:
-(void)application:(UIApplication *)application performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler{
[self methodToStartAllDownloads];
//Completion handler called somehow
}
The problem is that since all NSURLSessions have a completion handler and working async, it's hard to know when all of them are finished, so that I can call completionHandler(UIBackgroundFetchResultNewData)
in the method above. Is there a way to achieve something like calling the completion handler when all downloads are complete?