CreationKit Documentation

Class Location​Manager

public final class LocationManager: NSObject, CLLocationManagerDelegate  

A general LocationManger

LocationManager LocationManager CLLocationManagerDelegate CLLocationManagerDelegate LocationManager->CLLocationManagerDelegate NSObject NSObject LocationManager->NSObject

Nested Types


Errors that can occur in the LocationManager.

Conforms To




public var currentLocation: CLLocation?  

The most recently retrieved user location.

The value of this property is nil if no location data has ever been retrieved. In iOS 4.0 and later, this property may contain a more recent location object at launch time. Specifically, if significant location updates are running and your app is terminated, this property is updated with the most recent location data when your app is relaunched (and you create a new location manager object). This location data may be more recent than the last location event processed by your app. It is always a good idea to check the timestamp of the location stored in this property. If the receiver is currently gathering location data, but the minimum distance filter is large, the returned location might be relatively old. If it is, you can stop the receiver and start it again to force an update.



public func requestWhenInUseAuthorization()  

Ask the manager to request whenInUse authorization from the user.


public func requestAlwaysAuthorization()  

Ask the manager to request always authorization from the user.


public func requestWhenInUseAuthorizationIfNeeded()  

Ask the manager to request whenInUse authorization from the user if needed.


public func fetchCurrentLocation(
    desiredAccuracy: CLLocationAccuracy = kCLLocationAccuracyBest,
    completion: @escaping (_ result: Result<CLLocation, Errors>) -> Void

Askes the manager to fetch the users current location.


desired​Accuracy CLLocation​Accuracy

The desired accuracy of the location. Defaults to kCLLocationAccuracyBest.

completion @escaping (_ result:​ Result<CLLocation, Errors>) -> Void

The closure that will be called with the Result of the request.


The Result of the request.


func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus)  


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


func locationManager(_ manager: CLLocationManager, didFailWithError error: Error)