Joey Green
Joey Green

Reputation: 255

Waiting for current location from Core Location when app launches

I'm building an app where the first screen is waiting for Core Location to return the current location.

However sometimes ( usually ) the current location hasn't been retrieved via:

 locationManager(manager: CLLocationManager, didUpdateLocations locations [CLLocation])

by the time my first views viewDidLoad.

So my question is what is the best way to wait for the current location before my initial views viewDidLoad event occurs?

Upvotes: 0

Views: 529

Answers (1)

Serhii Mamontov
Serhii Mamontov

Reputation: 4932

There is no way to force UI to wait for location update before -viewDidLoad will get call. If your application doesn't require hight precision, you can use location property from CLLocationManager instance. If previously GPS has been used, that value will store information about previous location which has been received by device.

Upvotes: 1

Related Questions