Result Type was introduced as an improvement for error handling in Swift 5. It has been widely implemented by iOS developers. Since it was released, all third-party libraries also started to adopt it. But I notice that some developers are still using the old implementation probably because they already get used to it for a long time.

In this article, we are going to discuss and revise the basic usage of Result Type in the basic function and completion method. Let’s see the implementation without and with Result Type.

Without Using Result

First, we will take an example of a simple method to…

A simple and easy approach with no library needed

Apps using the Bottom Sheet view
Apps using the Bottom Sheet view
Apps using the bottom sheet view. Image by the author.

A bottom sheet modal view controller is a feature that has a great UI/UX design. It is very useful when we want to present a quick preview with minimal content. In fact, in most iOS implementations, it has a pan gesture feature (draggable) to simply dismiss the controller or expand the content by dragging the view to the top or bottom. The modal view controller can also be quickly dismissed by tapping the dimmed background.

This feature is currently implemented in many well-known apps such as Facebook, Slack, and Instagram.

What Will We Build?

Learn how to write, test, and deploy with ease

Drawing of user on laptop with cloud in background
Drawing of user on laptop with cloud in background
Photo from Firebase on YouTube.

Cloud Functions is a powerful feature provided by Firebase that is capable of managing intensive backend processes and handling event responses. It is very useful to reduce important logic performed in frontend apps.

In some scenarios, when a user logs into an app, we might need to send a welcome email or authentication code. In another example, when a user uploads photos from an app, we sometimes want to capture and modify it before it is stored. These logics need to be handled by the backend through the cloud function. …

Photo by Jeswin Thomas on Unsplash

Everyone should be familiar with Swift Collection including Array, Set and Dictionary. These three types are very useful in iOS Development to store data in collection form.

In this article, we are going to discuss the useful methods that can be used for Array. Array stores data with the same type in the ordered list and its elements are accessible by an index starting from zero. It can be stored with various data types (Int, String, Double, Any, Optional, etc) and also any type of user-defined Class or Struct.

Basic Syntax

Before we go through each method, let’s revise a bit the…

Say goodbye to boilerplate auto layout code and use the SnapKit library instead

pictures and shelves of decorative objects arranged on a wall
pictures and shelves of decorative objects arranged on a wall
Photo by Jonny Caspari on Unsplash

Most iOS projects nowadays gradually begin by removing Storyboard and Xib. Developers prefer to manage UI and layouts by writing constraints programmatically. It has become one of the best solutions to avoid merging conflicts, especially when working in a team.

The Auto Layout feature is available in Storyboard and Xib. It also can be written in code. Some developers prefer to use the pure API provided in Apple documentation, and others (including me) might prefer to use wrapper libraries such as Snapkit, PureLayout, and Cartography.

In this article, we are not going to discuss how to use all libraries or…

squash, undo latest commits, and more

list of Git messages
list of Git messages
Photo by Yancy Min on Unsplash

I believe nowadays every development should be done along with Git, a powerful collaboration tool to track every single change that occurs in a project so that developers can have a long history of things that have been done. This is very useful, especially if we are working in a team. But I personally will add it to all my projects even though I am working alone. Why? Because I can easily keep track of what I did in the past and quite quickly trace the bugs and mistakes.

In this article, we are going to discuss the useful tricks…

SwiftUI was firstly introduced in WWDC19 and the API has been rapidly improved in every single day. Since last year, Apple has made huge improvement in SwiftUI including layouts, animation and graphics.

There are so many sources that we can use to learn SwiftUI. But, which one will be the best to help us to quickly understand the whole concept. However, it depends and I won’t say that my approach will be the best for everyone. At least, after going through these steps, I can understand (not the whole) how to develop iOS apps in SwiftUI. …

Implement input form validation with two practical examples

Male on a hammock in front of a waterfall
Male on a hammock in front of a waterfall
Photo by Jeremy Bishop on Unsplash

I know that “RxSwift” itself sounds like a big and difficult thing. I was feeling the same when I started working on it. We are all learners. One of the best ways to learn is by adopting the implementation into an existing project. In this article, we will focus on the implementation of form validation in RxSwift.

RxSwift is Reactive Extensions (Rx) for Swift language. It is a well-known library and widely used by iOS developers, especially in MVVM patterns. For more understanding on definition and overview, you may refer to good articles written in Hackernoon and Raywenderlich.

Observable, Subscriber and Subjects

First, you…

Photo by Frederik Lipfert on Unsplash

In software development, we always focus on achieving the end result and sometimes overlook another important measurement to ensure we deliver the best apps to the user.

I know that most of the users nowadays have good Internet connectivity with high-speed WiFi and 4G. However, we cannot deny that at certain conditions the connection sometimes will become very poor and it surely affects the apps normal behaviour.

We as a developer should have a good preparation to handle the network failure, such as adding retry functions, network connectivity listener, and of course, showing a proper error message.

What Tools Do We Need?

Since WWDC19, Xcode…

Image by M W from Pixabay

It is common in iOS development where UIViewController becomes very messy and hard to manage because it is filled up with every single element, including Views, outlets, actions, cosmetics, layouts and business logics.

In fact, UIViewController should be very simple. It only need to manage the Views and observe the actions occur. In this tutorial, I would like to share one of the best practice that I always apply to my projects.


We are going to break down the screen into multiple UIView components and each UIView component will manage all the layouts and styles themselves. It also will take…

Mohd Hafiz

iOS Developer focusing on Swift — “Learn, that’s how we grow our skill”.

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