Photo by Bryan Garces on Unsplash

There’re many articles about design patterns that provide a good amount of information on either a comparison between different design patterns or on how to get started, and some are really good and can help you get a grasp of the theory and get you started. But some of them fall short in providing examples (real-life examples) for you to play around with them. If you are like me (a very visual and by example kind of learner) these articles may not be enough for you to feel confident to use on your projects.

Another is that there are many…

Photo by Mounzer Awad on Unsplash

Protocols and Extension are fantastic tools to help us be more productive.
I’m going to share a list of useful yet straightforward extensions and protocols that might help you organize your code and/or be more productive.

Bool Extension

We often want to toggle a bool and end up doing myBool = !myBool
This extension helps you avoid doing that.

Now you will only need to call myBool.toggle().

Optional Extension

Another annoying thing we have to deal with from time to time is using an optional Bool? in an if or any other control flow statements.
We sometimes end up using either a guard let…

Photo by Hello I’m Nik on Unsplash

As iOS developers, we are used to using delegates to move data asynchronously, and Apple sure loves to use them as well.
However, if you are like me (and many other iOS developers), avoiding using them is a significant part of our development steps, especially when using MVVM without RxSwift (or any other functional reactive programming library).

We are going to use closures in combination with enums to avoid using delegates between the ViewModel and the ViewController.
The project that we’ll work on uses delegates, and we will refactor it to use enums and closures instead.

If you are not…

On every project a time always come to make changes in he core services. This could come for different reasons, changes to the library that we use, deprecated methods on third party/Apple libraries or we just want to migrate to start using a new library or API.
This “small” change could impact our development speed, could take a lot of time to complete and/or could introduce bugs.

What we’ll do

On this article, we will refactor all networking related files into a module. …

The Problem

We all struggle from time to time when it comes to creating unit tests, mainly when the MainView depends on core/service classes (Network Service, API Services, etc.). There are design patterns that help us avoid this kind of situations, but honestly, not every time is doable, primarily when working on legacy code. So, here’s an easy to implement nice little “trick” that will help you test without having to make any significant refactoring.

The Solution

MVVM and protocol oriented programming is here to help us with our dependency injection. …

Please find the most recent version here.

As iOS developers, we tend to use a lot of delegates, sometimes even abuse of these poor little fellas. But, what else can we use? Right?

We know a few other options, but they might feel awkward or a bit of an overkill, depending on what we want to accomplish.

Real World Example

If you’ve been programming in iOS before the introduction of the UIAlertController (iOS 8), you probably used its predecessor alert, UIAlertView. One of the most noticeable changes between these two alerts is the way they interact with their caller. TheUIAlertView notified the view…

David Martínez-Lebron

iOS Engineer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store