swift - how to wait for requestLocation before proceeding? -


i'm requesting user location when button pressed triggers api call. don't want make api call before latitude/longitude values obtained requestlocation() call. thought poll while loop checking if optional variables latitude == nil || longitude == nil, sits in while loop forever. need have kind of waiting values because if don't send nils api call, since takes few seconds location. make sure api request isn't called until latitude/longitude values set requestlocation() call?

call api delegate method of cllocationmanagerdelegate

 func locationmanager(manager: cllocationmanager, didupdatelocations locations: [cllocation]) {     locationmanager.stopupdatinglocation()      let location = locations.last! cllocation      latittude = string(format: "%f", location.coordinate.latitude)     longitude = string(format: "%f", location.coordinate.longitude)  // call api here  } 

hope you.

thanks


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -