Book Image

Swift Cookbook

By : Cecil Costa, Cecil Costa
Book Image

Swift Cookbook

By: Cecil Costa, Cecil Costa

Overview of this book

Table of Contents (18 chapters)
Swift Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Hiring a van


In this recipe, we are going to give more functionalities to the cab application. Here, we will assume that the application won't call only cars, but will also make van services available. In this case, the van needs to specify its capacity, and as we are modernizing the code, we will do it using Swift. Of course, there will always be some code to type in Objective-C, so bear that in mind.

Getting ready

In this recipe, we are going to continue with the previous app, so make a copy of the previous recipe and open the project copy. Renaming the app Chapter 8 Car to Chapter 8 Vehicles would be good way to differentiate them.

How to do it...

Let's add the functionality of hiring a van by following these steps:

  1. First, click on the project navigator, then on the group, which contains the source code, and add a new Swift file called Van.swift. After we add the file, a new dialog appears asking whether you would like to create a bridge file. Click on Yes; otherwise, you have to create a...