I have multiple operations (they\'re AFNetworking requests) with completion blocks that takes some time to execute, and a Core Data object that needs to be saved at the end
My requirements were those of do many request from an array of String (URL)
func updateSourceData(element: Int) {
if element > availableUrls.count - 1 {
return
}
let service = SourceDataServiceDao()
let currentUrl = availableUrls[element]
service.fooCall(url: currentUrl, completion: { (response, error) -> Void in
self.updateSourceData(element + 1)
})
}
Obviously, in this way calls are made in cascade, not N asynchronous calls.