Contents

CLLocationManager

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

Declaration

class CLLocationManager

Mentioned in

Overview

A CLLocationManager object is the central place to manage your app’s location-related behaviors. Use a location-manager object to configure, start, and stop location services. You might use these services to:

  • Track large or small changes in the user’s current location with a configurable degree of accuracy.

  • Report heading changes from the onboard compass.

  • Monitor geographical regions of interest and generate events when someone enters or leaves those regions.

  • Report the range to nearby Bluetooth beacons.

Create one or more location-manager objects in your app and use them where you need location data. After you create a location-manager object, configure it so that Core Location knows how often to report location changes. In particular, configure the distanceFilter and desiredAccuracy properties with values that reflect your app’s needs.

A CLLocationManager object reports all location-related updates to its delegate object, which is an object that conforms to the CLLocationManagerDelegate protocol. Assign the delegate immediately when you configure your location manager, because the system reports the app’s authorization status to the delegate’s locationManagerDidChangeAuthorization(_:) method after the location manager finishes initializing itself. Core Location calls the methods of your delegate object using the RunLoop of the thread on which you initialized the CLLocationManager object. That thread must itself have an active RunLoop, like the one found in your app’s main thread.

For more information, see Configuring your app to use location services.

Topics

Determining the availability of services

Receiving data from location services

Requesting authorization for location services

Specifying distance and accuracy

Running the standard location service

Running the significant change location service

Running the visits location service

Running the heading service

Running the region-monitoring service

Performing beacon ranging

Monitoring location push notifications

Getting recent location and heading data

Deferring location updates

Deprecated

Instance Methods

See Also

Essentials