dispatchgroup

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

青春壹個敷衍的年華 提交于 2020-06-29 03:45:55
问题 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 load additional data. The data will populate the cells in a UITableViewController . Ideally this process would happen in the following exact sequence: query 500 items cell_1 load additional data. cell_1 render data and display in

How can you use Dispatch Groups to wait to call multiple functions that depend on different data?

☆樱花仙子☆ 提交于 2020-02-21 04:54:15
问题 I have three variables, a , b and c . I have three asynchronous functions with completion blocks to update these variables and three more functions that do some work with only some of the data. I'm making sure that the working functions wait until all the data is updated with a DispatchGroup . // The Data var a: String? var b: String? var c: String? // The Update let group = DispatchGroup() group.enter() updateA() { group.leave() } group.enter() updateB() { group.leave() } group.enter()