Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

Share this Page URL

Chapter 18: Where Am I? Finding Your Way... > The Location Manager - Pg. 634

634 CHAPTER 18: Where Am I? Finding Your Way with Core Location The technologies that Core Location depends on are hidden from your application. We don't tell Core Location whether to use GPS, triangulation, or WPS. We just tell it how accurate we would like it to be, and it will decide from the technologies available to it which is best for fulfilling your request. The Location Manager The Core Location API is actually fairly easy to use. The main class we'll work with is CLLocationManager, usually referred to as the location manager. To interact with Core Location, you need to create an instance of the location manager, like this: CLLocationManager *locationManager = [[CLLocationManager alloc] init]; This creates an instance of the location manager, but it doesn't actually start polling for your location. You must create an object that conforms to the CLLocationManagerDelegate protocol and assign it as the location manager's delegate. The location manager will call delegate methods when location information becomes available or changes. The process of determining location may take some time--even a few seconds. Setting the Desired Accuracy After you set the delegate, you also want to set the requested accuracy. As we mentioned, don't specify a degree of accuracy any greater than you absolutely need. If you're writing an application that just needs to know which state or country the phone is