Questions tagged [dispatchgroup]

A group of tasks that you monitor as a single unit in Swift language by Apple.

47 questions
0
votes
1 answer

Dispatch group don't return fetched data

I'm trying to use DispatchGroup for fetching data from multiple request. I cant understand why print(weatherData.fact.pressureMm!) is working, but data didn't appending inside dataArray and print(dataArray?[0].fact.pressureMm ?? "nil") print…
0
votes
2 answers

Swift Code Running Twice When It Should Not

I have an escaping function, which completes once a condition is met: private func xxxfastLoadLSecurityDescriptions(session: URLSession, mySymbols: [String]?, completion: @escaping(Bool) ->()) { var counter = mySymbols?.count…
Marco
  • 81
  • 1
  • 8
0
votes
1 answer

How to use Dispatch Group in a loop with asynchronous Function Swift?

I have checked all the questions regarding this topic but none of them helped. I have a code like below. Now as soon as the code enters the for id in stringArray loop, it gets executed for the stringArray.count times without even entering the…
Fahad Ali
  • 205
  • 1
  • 9
0
votes
2 answers

Execute for loop with optional asynchronous calls in order

I have a function to retrieve some data which I am doing with a for-loop. Inside that it is possible that an asynchronous function is called but not necessarily. I am also firing a completion after the loop is finished which I am doing with…
Chris
  • 1,828
  • 6
  • 40
  • 108
0
votes
0 answers

updating multiple firestore collections in loop

i'm trying to update multiple collections, the below code accessing getDocument only on the last item in the array, i tried to solve the issue by putting the getDocument in new function and using completion handler and dispatchGroup. pp.order…
0
votes
0 answers

Getting this error when adding new data... Thread 1: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)

So when I'm loading up my App for the first time and I'm adding in my first piece of data, the tableView reloads and the section/rows are added properly, but when I enter in any additional data after that, the new data gets added but my original…
user12329049
0
votes
1 answer

Why DispatchGroup is not working correctly

I want the function to wait for the 1st function to get the data from the firebase first then execute the 2nd one but it turn out that it is not working in a correct order func getMenuData(){ getMenu() getIngredient() getRecipe() …
WPN
  • 63
  • 1
  • 5
0
votes
1 answer

Using `DispatchGroup` or some concurency construct to load data and populate cells in `UITableViewController` sequentially

Platform: I am on swift 4 and xcode 11.4 Use case and desired behavior The app is loading a feed with potentially 100s or 1000s of items, let's say 500 items. The 500 items will be grabbed once using Amplify's GraphQL query, then each item will then…
xiaolingxiao
  • 4,793
  • 5
  • 41
  • 88
0
votes
2 answers

How to run a function in a for loop sequentially

I have a set of buttons in a stack view. Each button when pressed plays a different sound. I have a separate button (loop button) that when pressed calls the loopButtonPressed function. My goal is that when this loop button is pressed, it will loop…
Max Dolensky
  • 107
  • 7
0
votes
1 answer

How to make the for loop stop for the asynchronous request Swift 5

Here's the func that I want the for loop to wait for the completion from func getVenueDetails and if completion is true break out of the loop, and if not continue with the next venue id. func searchVenues(lat: Double, lng: Double) { let…
Lina
  • 28
  • 5
0
votes
1 answer

Adding dependency of one BlockOperation on another is not working properly in swift

I have multiple api's in a controller and after successful response I have to reload the UITableView. For now I started with two api having second api dependency on first one using BlockOperation and DispatchGroup in it. First in viewDidLoad:…
Amit
  • 4,837
  • 5
  • 31
  • 46
-1
votes
1 answer

dataTask() in a loop: Waiting and breaking

My app downloads a couple of files from a server, using a URLSessionDataTask. When a downloads finishes successfully (and without any errors), then it should start the next download. If there is any type of error, then the whole thing has to abort…
Neph
  • 1,823
  • 2
  • 31
  • 69
-1
votes
2 answers

group.notify never called in dispatchGroup

I have group and queue let group = DispatchGroup() let queue = DispatchQueue(label: "downloadImages", attributes: .concurrent) In my function i send 3 requests func getImages() { networkService.getImages(find: film.originalTitle) { [weak…
protodimbo
  • 35
  • 1
  • 8
-1
votes
1 answer

Call two API's and build structure - iOS - Swift

i know this is common but couldn't find answers. I thought of using dispatchGroups but not sure how I could do Requirement: API 1 gives id, I need to construct url with that id and call another API to fetch imageUrl and then build struct with…
Ashh
  • 569
  • 1
  • 6
  • 28
-2
votes
1 answer

What does exclamation in purple mean in Xcode?

What does the exclamation in purple mean?