completionhandler - Swift 3 Completion Handler on Google Places Lookup. Due to delay how do I know when Im "done"? -


sorry, newbie here , ive read extensively completion handlers, dispatch queues , groups can't head around this.

my app loads array of google place ids , wants query google full details on each place. problem is, due async processing google lookup place returns , callback happens further down line whats "proper way" know when last bit of data has come in inquiries because function ends immedately ?

code attached. in advance.

func testfunc() {      let googleplaceids = ["chij5ftxdp8mk4crjikzek6l6nm", "chij9wd6mgygk4criwd0_bkohhg", "chijaext08ask4crkcgpggzypu8", "chijkrks4bapk4crxct8-sjxndi", "chij3wdv_2zx5ikrtd0hg2i1lhe", "chijb4wusi5w44krnere7ywqaja"]      let placesclient = gmsplacesclient()      placeid in googleplaceids {          placesclient.lookupplaceid(placeid, callback: { (place, error) in              if let error = error {                 print("lookup place id query error: \(error.localizeddescription)")                 return             }              guard let place = place else {                 print("no place details \(placeid)")                 return             }              print("place name = \(place.name)")          })      }      print("done")  } 


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -