Location

Core Location provides facilities for the device to determine and report its location (location services). It takes advantage of three sensors:

Wi-Fi
The device (if Wi-Fi is turned on) may scan for nearby Wi-Fi devices and compare these against an online database.
Cell
The device (if it has cell capabilities) may compare nearby telephone cell towers against an online database.
GPS
The device’s GPS (if it has one) may be able to obtain a position fix from GPS satellites.

Core Location will automatically use whatever facilities the device does have; all you have to do is ask for the device’s location. Core Location allows you to specify how accurate a position fix you want; more accurate fixes may require more time.

The notion of a location is encapsulated by the CLLocation class and its properties, which include:

coordinate
A CLLocationCoordinate2D; see Chapter 34.
altitude
A CLLocationDistance, which is a double representing a number of meters.
speed
A CLLocationSpeed, which is a double representing meters per second.
heading
A CLLocationDirection, which is a double representing degrees (not radians!) clockwise from north.
horizontalAccuracy
A CLLocationAccuracy, which is a double representing meters.

In addition to the sensor-related considerations I mentioned a moment ago, use of Core Location poses the following challenges:

  • Accuracy of a reported location may vary depending on a number of factors. The GPS is the most accurate location sensor, but it takes ...

Get Programming iOS 6, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.