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

Storing coordinates


Now, it is time to leave some breadcrumbs. At this point, we have to store the path we have been working with all this while. For this feature, we will use Reactive Core Data, which is a ReactiveCocoa extension that uses Core Data.

As we are only going to write the coordinates, we should create a class for this purpose. Remember that the objects that are stored using Core Data must inherit from NSManagedObject; therefore, let's start creating this new class.

Use commandN to add a new file in your project, and call it Coordinate.swift. Start importing Core Data to make the NSManagedObject inheritance possible:

import CoreData 

Create a class called Coordinate with two properties, latitude and longitude. Both of these should be Double with the @NSManaged modifier as they must be stored in the database. Add the @objc(Coordinate) modifier to make this class visible with the help of Objective-C, and don't forget that Reactive Core Data was written in Objective-C. The...