The object that you use to start and stop the delivery of location-related events to your app.
- iOS 2.0+
- macOS 10.6+
- Mac Catalyst 13.0+Beta
- tvOS 9.0+
- watchOS 2.0+
- Core Location
You use instances of this class to configure, start, and stop the Core Location services. A location manager object supports the following location-related activities:
Tracking large or small changes in the user’s current location with a configurable degree of accuracy.
Reporting heading changes from the onboard compass. (iOS only)
Monitoring distinct regions of interest and generating location events when the user enters or leaves those regions.
Deferring the delivery of location updates while the app is in the background. (iOS only)
Reporting the range to nearby beacons.
When you are ready to use location services, follow these steps:
Check to see if your app is authorized to use location services and request permission if your app's authorization status is not yet determined, as described in Requesting Permission to Use Location Services.
Check to see if the appropriate location services are available for you to use, as described in Determining the Availability of Location Services.
Create an instance of the
CLLocationclass and store a strong reference to it somewhere in your app.
Keeping a strong reference to the location manager object is required until all tasks involving that object are complete. Because most location manager tasks run asynchronously, storing your location manager in a local variable is insufficient.
Call the appropriate method to start the delivery of events.
For the services you use, configure any properties associated with that service accurately. Core Location manages power aggressively by turning off hardware when it is not needed. For example, setting the desired accuracy for location events to one kilometer gives the location manager the flexibility to turn off GPS hardware and rely solely on the WiFi or cell radios, which can lead to significant power savings.
All location- and heading-related updates are delivered to the associated delegate object, which is a custom object that you provide. For information about the delegate methods you use to receive events, see