Better Programming

Advice for programmers.

Follow publication

Member-only story

Implement a Clean VIP Architecture in Swift 5

An improvement on the VIPER design pattern

Zafar Ivaev
Better Programming
Published in
6 min readJun 4, 2020

--

Photo by Daniel Korpai on Unsplash

In this article, we’ll learn how to implement a Clean VIP architecture in Swift. We’ll do so by creating a Core Data powered app that saves, deletes, and displays items in a UITableView. It also has a details page to illustrate how we navigate and pass data between modules.

The VIP pattern was created to address some issues of the VIPER architecture. One problem was that the Presenter (P) component may become too large — as it’s responsible for handling UI actions and preparing data for the view. To facilitate the single responsibility principle the relationship between objects was altered. While the VIPER’s V part means both ViewController and a UIView, the VIP’s “V” means simply ViewController. Therefore, the UIView is a separate component now, which makes view controllers a little bit thinner.

Before we start, let’s understand the terminology behind the VIP pattern. Each module or scene usually involves the following components with their corresponding responsibilities:

  • View: Anything that is a UIView subclass. It should be reusable and as passive as possible.
  • ViewController: An object that is created to manage the behavior of a specific view. May act as a data source or event handler. Calls…

--

--

Zafar Ivaev
Zafar Ivaev

Written by Zafar Ivaev

Senior iOS Engineer. I write about features of Swift and iOS development practices.

Responses (4)

Write a response