Photo by Markus Spiske from Pexels

Learning outcomes:

  1. Understand what are Generic Functions and Generic Types
  2. Understand what are Type Constraints
  3. Use generic functions to write cleaner code

Generics is one of the most powerful tools in Swift. It enables us to write clean, flexible, and reusable code to avoid duplications. Great, isn’t it? Now the question is: How does this tool help me to write cleaner and flexible code? The answer is not that simple, but I promise you will be using generics with confidence after reading this article. Let’s start by saying that generics covers topics like:

  1. Generic Functions
  2. Generic Types
  3. Type Constraints
  4. Associated…


Photo by Startup Stock Photos from Pexels

Learning outcomes

  1. Learn how to use XCTestExpectation clas
  2. Take advantage of XCTestExpectation class to clean up the source code of your tests

When test driving or writing tests for some tasks we usually have our given, our when, and finally our then. This is easy to picture when we create tests for synchronous tasks. What happens when we have to test driving tasks that don’t behave the same way? If a task is asynchronous, How do we get the results to make our assertions in our test? The answer is fairly simple, Apple provides us with XCTestExpectation class. …


Photo by Markus Spiske from Pexels

Learning outcomes

  1. Learn about Swift available patterns
  2. Learn how we can use pattern matching to clean up our source code

The term may sound complex to you if you have worked with Swift before, and either you don’t know what patterns are or which available patterns exist in Swift. The good news is that you’ve been working with patterns and you don’t know that(yet 🙂).

Do these tasks sound familiar to you?

  1. Declare a variable/constant (Identifier pattern)
  2. Use a wildcard to ignore an expression’s returned value (Wildcard Pattern)
  3. Declare a tuple (Tuple Pattern)
  4. Verify an enum value on a switch…


Memory handling and types of references

Photo by Jorge Ramirez on Unsplash

Working in our iOS apps can be very challenging in terms of memory handling, this means we need to be very careful with the object instances allocated in memory and guarantee their correct deallocation.

As you may know instances are deallocated from memory by the ARC or Automatic Reference Counting and there are two types of references on iOS: Strong and Weak.

Strong references are the default type of reference, let’s see a simple object declaration. Imagine that we have a class called Person and we declare an object as follows:

var person = Person()

In the previous declaration we…

Luis Piura

iOS Developer

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