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

Organizing a dinner room


In this recipe, we will learn how to use other features from the Swift programming language. We will copy the range of elements from an array, use dictionaries, subscripts, switches, and name a loop.

For this app, we will create a dinner for a company. In this case, it's not a wedding table where couples must be seated next to each other, we only need that people of the same group should be seated together on the same table, probably because they are from the same team or something like this.

We will create a class that represents a room. To add a new guest into this room, we will need to specify the name of someone who belongs to this group, which is already inside the room. If the person we want to add to this room is the first one, we will use the nil value as the name of the person who belongs to this group.

In the case of adding someone to a table, that is, full one group of this table must be reallocated to another table. Of course, we won't use the most optimized...