Search
 
SCRIPT & CODE EXAMPLE
 

SWIFT

swift await async

func myFunction() {
    let array = [Object]()
    let group = DispatchGroup() // initialize

    array.forEach { obj in

        // Here is an example of an asynchronous request which use a callback
        group.enter() // wait
        LogoRequest.init().downloadImage(url: obj.url) { (data) in
            if (data) {
                group.leave() // continue the loop
            }
        }
    }

    group.notify(queue: .main) {
        // do something here when loop finished
    }
}
Comment

PREVIOUS NEXT
Code Example
Swift :: UICollectionviewcontroller reload data 
Swift :: addition of numbers from array swift 
Swift :: swift allow gesture recognizer over others 
Swift :: how to delete from list tvos swiftui coredata 
Ruby :: rails include route helpers in console 
Ruby :: devise generate controller 
Ruby :: ruby json parse symbolize_keys 
Ruby :: ruby get current datetime utc 
Ruby :: rails uniqueness 
Ruby :: eager load polymorphic rails 
Ruby :: How can I rename a database column in a Ruby on Rails migration? 
Ruby :: ruby reference a file in a gem 
Ruby :: ruby file get line number 
Ruby :: rails logger color 
Ruby :: ruby deep merge 
Ruby :: is there a way of changing the key of a hash 
Ruby :: rails get asset path from console 
Ruby :: how to generate a controller in rails 
Ruby :: ruby remove last element of string 
Ruby :: rails generate rake task 
Ruby :: check type in ruby 
Ruby :: heroku run rails 
Ruby :: ruby while 
Ruby :: ruby array split into groups 
Ruby :: call the api from ruby 
Ruby :: rails duplicate record 
Ruby :: ruby sinatra helper 
Ruby :: Validate French phone numbers 
Ruby :: include module in rails different folder in rails 
Ruby :: rails convert euro to dollar 
ADD CONTENT
Topic
Content
Source link
Name
2+6 =