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

Being aware of cyclones


Sometimes it's good that our mobile phone or even our computer can tell us the weather predictions, mainly when some kind of disaster is going to come, such as a storm, an earthquake, or a cyclone. To do this, the application must continuously ask for the weather prediction from the Internet, but it shouldn't block the application's operation.

In this recipe, we will develop an application that will ask every 5 minutes for cyclone predictions; in the case of finding one cyclone, it will write down the URL where the user can retrieve information about the cyclone detected. If the application is running in the background, it will throw a notification.

Here, we will create a multitask using the Grand Central Dispatch, which is the way Apple recommends to use it.

Getting ready

Create an application called Chapter 5 Cyclones and add a file called CycloneChecker.swift. Also, check whether you have Internet connection on your computer or your device.

How to do it...

Follow these...