Book Image

Reactive Programming with Swift

By : Cecil Costa
Book Image

Reactive Programming with Swift

By: Cecil Costa

Overview of this book

<p><span id="description" class="sugar_field">Reactive programming helps you write applications that are more powerful and efficient. You can write more software, help more people, and create applications that scale. Reactive programming is a growing paradigm that we will help you set to work in Swift.</span></p> <p><span class="sugar_field"><span id="description" class="sugar_field"> Reactive Programming with Swift guides you through migrating from the traditional way of developing to the new ReactiveCocoa framework, which uses Swift as its main programming language. You will learn how to develop with this framework, debug code, create unit tests, use additional frameworks, and convert a traditional framework into a ReactiveCocoa one.</span></span></p> <p><span class="sugar_field"><span id="description" class="sugar_field"><span id="description" class="sugar_field"> Starting with a crash course on the fundamental concepts of Reactive programming, we’ll set you up so you’re ready to create reactive applications. We’ll then move on to topics such as Graphical events, Streaming, and Core data, which will help you dive deeper with advanced programming. The concept of switching your programming concepts from imperative to functional reactive programming will also be covered. By the end of this book, you will be able to successfully create highly functional apps using Swift.</span> </span></span></p>
Table of Contents (14 chapters)
Reactive Programming with Swift
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface

Retrieving information from GPS


In this application, GPS will allow us to track where the user has been; this will give us an idea about where the pictures might have been taken. As we are going to use GPS, we need to add a record in info.plist that gives the user a message saying that we are going to use this sensor. This is a requirement as of iOS 8.

Click on the info.plist file located in your Project Navigator. Add a new record and set NSLocationWhenInUseUsageDescription as key and as value a phrase like This app needs permission for using GPS. Here, you have a sample:

We have used NSLocationWhenInUseUsageDescription instead of NSLocationAlwaysUsageDescription as our extension uses only the first one. If you need to use the second one, you have the advantage of being able to easily change DRPReactiveCoreLocation in the source code.

Now, we are ready to create a new View Controller that will use GPS. Using command N, add a new Swift file called TakePicturesViewController.swift. Just...