Protocol

CLLocationManagerDelegate

The methods that you use to receive events from an associated location manager object.

Overview

The location manager calls the methods of this delegate to report location-related events to your app. Implement this protocol in an app-specific object and use the methods to update your app. For example, you might use the current location to update the user's position on a map or you might return search results relevant only to the user's current location.

Assign your delegate object to the delegate property of the CLLocationManager object before starting any services. Core Location may report a cached value to your delegate immediately after you start the service, followed by a more current value later. Check the time stamp of any data objects you receive before using them.

The methods of your delegate object are called from the thread in which you started the corresponding location services. That thread must itself have an active run loop, like the one found in your application’s main thread.

Topics

Responding to Location Events

func locationManager(CLLocationManager, didUpdateLocations: [CLLocation])

Tells the delegate that new location data is available.

func locationManager(CLLocationManager, didFailWithError: Error)

Tells the delegate that the location manager was unable to retrieve a location value.

func locationManager(CLLocationManager, didFinishDeferredUpdatesWithError: Error?)

Tells the delegate that updates will no longer be deferred.

func locationManager(CLLocationManager, didUpdateTo: CLLocation, from: CLLocation)

Tells the delegate that a new location value is available.

Pausing Location Updates

func locationManagerDidPauseLocationUpdates(CLLocationManager)

Tells the delegate that location updates were paused.

func locationManagerDidResumeLocationUpdates(CLLocationManager)

Tells the delegate that the delivery of location updates has resumed.

Responding to Heading Events

func locationManager(CLLocationManager, didUpdateHeading: CLHeading)

Tells the delegate that the location manager received updated heading information.

func locationManagerShouldDisplayHeadingCalibration(CLLocationManager)

Asks the delegate whether the heading calibration alert should be displayed.

Responding to Region Events

func locationManager(CLLocationManager, didEnterRegion: CLRegion)

Tells the delegate that the user entered the specified region.

func locationManager(CLLocationManager, didExitRegion: CLRegion)

Tells the delegate that the user left the specified region.

func locationManager(CLLocationManager, didDetermineState: CLRegionState, for: CLRegion)

Tells the delegate about the state of the specified region.

func locationManager(CLLocationManager, didStartMonitoringFor: CLRegion)

Tells the delegate that a new region is being monitored.

Responding to Ranging Events

func locationManager(CLLocationManager, rangingBeaconsDidFailFor: CLBeaconRegion, withError: Error)

Tells the delegate that an error occurred while gathering ranging information for a set of beacons.

Responding to Visit Events

func locationManager(CLLocationManager, didVisit: CLVisit)

Tells the delegate that a new visit-related event was received.

Responding to Authorization Changes

func locationManager(CLLocationManager, didChangeAuthorization: CLAuthorizationStatus)

Tells the delegate that the authorization status for the application changed.

Relationships

Inherits From

See Also

First Steps

Choosing the Authorization Level for Location Services

Choose the appropriate level of access to location data for your app.

Determining the Availability of Location Services

Determine which location services are active and available on the user's device.

class CLLocationManager

The object that you use to start and stop the delivery of location-related events to your app.