Book Image

Swift Cookbook

Book Image

Swift Cookbook

Overview of this book

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

Tracking your phone activity


Imagine that you would like to track where your phone received (or made) a call by recording when a human head was close to the phone; you would want to create an app that will register some data, such as the current time and the phone coordinates, every time the proximity sensor detects something near the front face of the phone.

Although we are going to use SQLite again, we are not going to write any SQL statements. This time, we are going to use a framework that uses only Swift types and objects so that we don't have to worry about converting types from Swift to C and from C to Swift.

Getting ready

For this recipe, we will need to download an external framework called SQLite.swift. To do this, open your favorite web browser and go to https://github.com/stephencelis/SQLite.swift. Once the website is open, click on the "Download ZIP" icon. If you have used Safari, the downloaded file would probably be already unzipped. In case of using another web browser, unzip...