Instance Method

startUpdatingLocation

Starts the generation of updates that report the user’s current location.

Declaration

- (void)startUpdatingLocation;

Discussion

This method returns immediately. Calling this method causes the location manager to obtain an initial location fix (which may take several seconds) and notify your delegate by calling its locationManager:didUpdateLocations: method. After that, the receiver generates update events primarily when the value in the distanceFilter property is exceeded. Updates may be delivered in other situations though. For example, the receiver may send another notification if the hardware gathers a more accurate location reading.

Calling this method several times in succession does not automatically result in new events being generated. Calling stopUpdatingLocation in between, however, does cause a new initial event to be sent the next time you call this method.

If you start this service and your app is suspended, the system stops the delivery of events until your app starts running again (either in the foreground or background). If your app is terminated, the delivery of new location events stops altogether. Therefore, if your app needs to receive location events while in the background, it must include the UIBackgroundModes key (with the location value) in its Info.plist file.

In addition to your delegate object implementing the locationManager:didUpdateLocations: method, it should also implement the locationManager:didFailWithError: method to respond to potential errors.

See Also

Initiating Standard Location Updates

- stopUpdatingLocation

Stops the generation of location updates.

- requestLocation

Requests the one-time delivery of the user’s current location.

pausesLocationUpdatesAutomatically

A Boolean value indicating whether the location manager object may pause location updates.

allowsBackgroundLocationUpdates

A Boolean value indicating whether the app should receive location updates when suspended.

showsBackgroundLocationIndicator

A Boolean indicating whether the status bar changes its appearance when an app uses location services in the background.

distanceFilter

The minimum distance (measured in meters) a device must move horizontally before an update event is generated.

CLLocationDistanceMax

A constant indicating the maximum distance.

kCLDistanceFilterNone

A constant indicating that all movement should be reported.

desiredAccuracy

The accuracy of the location data.

activityType

The type of user activity associated with the location updates.

CLActivityType

Constants indicating the type of activity associated with location updates.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software