How to read the current location of an iOS device

Thanks to the Core Location framework we can get the current location of our device. We need to create a CLLocationManager object and start it. Its delegate method will return CLLocation objects which among other items will contain the longitude and latitude of our device.


Here’s how to do it. Let’s create the manager as a property (self.manager) and initialise it with this custom method:


Then we start the manager:

We can also stop the manager when we no longer need to track the location (good to conserve battery power):

Reacting to updates

Now that the manager is running we can implement two methods that will be called by the manager every time there is an update or a failure to get a location. For this to work we need to conform to the following protocol, and of course import the CoreLocation framework (don’t forget to link the latter in your project):

Here are the delegate methods we’re interested in:


In the first method all I’m doing is to display the longitude and latitude in two labels. Both are float values, derived from a CLLocation object that is available in the locations array (this is new in iOS 7). This array contains previous location objects as well and is amended every time this method is called. The most current location is at the end of the array (we get it via [locations lastObject]).

I’ve created a Demo Project on GitHub called Locations – feel free to fork and examine how it works.

About Jay Versluis

Jay is a medical miracle known as Super Survivor. He runs two YouTube channels, five websites and several podcast feeds. To see what else he's up to, and to support him on his mission to make the world a better place, check out his Patreon Campaign.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.