The first thing that a user needs to know when he opens the map is where he is on the map. Getting the user's current location helps him to get an idea of his location, nearby places, and points of interest. To respect the user's privacy, apps can't get the user's current location without the user granting them access to it. In this section, we will see how to ask for permission to access location services and display the current location to the user.
To help display the current location, perform the following steps:
Create a new Xcode project with the Single View Application template and with name the
LocationServicesDemo
.In the view controller in storyboard, embed the view controller in Navigation Controller. Then, drag a navigation item from Object Library.
Add a UIBarButtonItem at the top right of the navigation item with the title
Locate Me
.Now, add a map view that will be responsible for displaying maps. Drag a MKMapView from Object Library and place...