Book Image

Test-Driven iOS Development with Swift

By : Dr. Dominik Hauser
Book Image

Test-Driven iOS Development with Swift

By: Dr. Dominik Hauser

Overview of this book

Test-driven development (TDD) is a proven way to find software bugs early. Writing tests before your code improves the structure and maintainability of your app. Test-Driven iOS Development with Swift will help you understand the process of TDD and how it impacts your applications written in Swift. Through practical, real-world examples, you’ll start seeing how to implement TDD in context. We will begin with an overview of your TDD workflow and then deep-dive into unit testing concepts and code cycles. We will showcase the workings of functional tests, which will help you improve the user interface. Finally, you will learn about automating deployments and continuous integration to run an environment.
Table of Contents (15 chapters)
Test-Driven iOS Development with Swift
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Chapter 3. A Test-Driven Data Model

iOS apps are often developed using a design pattern called Model-View-Controller (MVC). In this pattern, each class (or struct or enum) is either a model object, view, or a controller. Model objects are responsible for storing data. They should be independent from the kind of presentation by the UI. For example, it should be possible to use the same model object for an iOS app and a command-line tool on Mac.

View objects are the presenters of the data. They are responsible for making the objects visible (or hearable in the case of a VoiceOver-enabled app) for the user. Views are special for the device that the app is executed on. In the case of a cross-platform application, view objects cannot be shared. Each platform needs its own implementation of a view layer.

Controller objects communicate between the model and view objects. They are responsible for making the model objects presentable.

We will use MVC for our to-do app because it is one of the easiest...