Book Image

iOS Programming Cookbook

By : Hossam Ghareeb
Book Image

iOS Programming Cookbook

By: Hossam Ghareeb

Overview of this book

Do you want to understand all the facets of iOS programming and build complex iOS apps? Then you have come to the right place. This problem-solution guide will help you to eliminate expensive learning curves and focus on specific issues to make you proficient at tasks and the speed-up time involved. Beginning with some advanced UI components such as Stack Views and UICollectionView, you will gradually move on to building an interface efficiently. You will work through adding gesture recognizer and touch elements on table cells for custom actions. You will work with the Photos framework to access and manipulate photos. You will then prepare your app for multitasking and write responsive and highly efficient apps. Next, you will integrate maps and core location services while making your app more secure through various encryption methods. Finally, you will dive deep into the advanced techniques of implementing notifications while working with memory management and optimizing the performance of your apps. By the end of the book, you will master most of the latest iOS 10 frameworks.
Table of Contents (22 chapters)
iOS Programming Cookbook
About the Author
About the Reviewer
Customer Feedback

Getting directions between locations

Getting directions between source and destination locations is one of the common operations when dealing with maps and navigation apps. You can get directions from the current location or any other source location to the destination location and those directions will differ depending on the mode of transit, such as walking, driving, cycling, or public transport. In this section, we will learn how to get the direction between any two source and destination points and display them on the map.

How to do it...

To get directions between a source and destination, perform the following steps:

  1. Let's continue using our demo to add a way to display directions between two locations.

  2. Go to storyboard and open our view controller to add a UIButton at the bottom with the title Directions. Add constraints to the button to stick it to the bottom, like this:

  3. Add an IBAction function, didClickOnDirections, to the button in ViewController.swift like this:

          @IBAction func...