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

Introduction


We could say that structures are something similar to classes. They store values with attributes, and they have initializers and methods. But their usage is a bit different. The idea of structs in Swift came from Objective-C, which by itself was using the C struct.

We will also use generics, so we can create generic containers. The idea of generics is not new; other languages such as C++ and Java already had it. However, this feature didn't exist in Objective-C, so the programmer was responsible for casting the retrieved data and as a consequence of this, the code was unsafe.