In WWDC 2021, Apple introduce Searchable as a way of allowing user to search from a List.

The process is a rather simple and straight forward way which will make writing code a lot easier.

Prerequisites

To follow along this tutorial, you’ll need some basic knowledge in:

  • A basic familiarity with Swift.

Setting up List

Your new restaurant is launching a new app and you are thinking of making use of the new technology that Apple has released by implementing Searchable allowing user to search for their favorite food.

But first, you will need to create a list…


The term code smell was introduced by Kent Beck on WardsWiki in the late 1990s. Code smell shouldn’t be viewed as a bug but they are an indication of weakness in design that could potentially slow down future development or increase the risk of bugs or failures in the future.

Code smell would often lead to refactoring.

Let’s identify some of the code smell in Swift

DUPLICATED CODES

We need to prevent identical or similar code that exist in more than one location. Duplicated codes is the definition of redundancy and could often be refactored easily by using a function.

Below is…


The core idea of functional programming is to rely less on polymorphism and loops but instead uses higher-order function for abstraction such as map, filter and reduce functions for iteration.

Swift is a multi-paradigm language which means it could conform to more than one paradigm such as object-oriented, functional, imperative and block structured language.

The key benefit of using functional programming is:

  • Less prone to bugs and easier to understand than imperative code.

Functional programming is a programming paradigm — a style of building the structure and…


The Clean Architecture (VIP) is an architecture pattern that separates objects into three distinct types mainly made up of View, Interactor and Presenter

With VIP, the responsibilities are divided equally where

  • View delegate user interaction to Interactor.

As the app grows larger, you will have additional components such as Router and Worker. …


The View Interactor Presenter Entity Router (VIPER) is an architecture pattern that separates objects into five distinct types mainly made up of View, Interactor, Presenter, Entity and Router.

VIPER divides the logical structure into distinct layer of responsiblities which then isolate the app’s dependencies. With that you, there are multiple components which play different role here:

  • View delegate user interaction to Presenter.


The Model View Presenter (MVP) is an architecture pattern that separates objects into three distinct types mainly made up of Models, Views and Presenter.

MVP was invented to facilitate unit testing and to improve separation of concerns in presentation logic.

Each of the components in MVP play an important role:

  • Model holds application data.

The presenter has no dependences to UIKit and there is a reference between View and Presenter where they both know about each other existence.

When should you use it?

MVP becomes the choice after MVC…


The Model View ViewModel (MVVM) is an architecture pattern that separates objects into three distinct types mainly made up of Models, Views and ViewModels.

Microsoft architects Ken Cooper and Ted Peters invent Model View ViewModel (MVVM). The goal is to simplify event-driven programming of user interfaces. Each of the components in MVVM play an important role:

  • Model holds application data.

When should you use it?

As your project scale bigger and bigger, you should consider moving into MVVM because of its ability of segregating…


The Model-View-Controller (MVC) is an architecture pattern that separates objects into three distinct types mainly made up of Models, Views and Controllers.

It is worth to understand that Controller actually contains both View and Model. Each of the components holds a different responsibilities where:

  • Models hold application data.

MVC is a very common design pattern in developing iOS apps as it is the easiest to use and beginner friendly.

Controllers usually have strong properties for the Model and View for ease of access. …


Ship your own libraries

Hand holding an iPhone
Hand holding an iPhone
Photo by Youssef Sarhan on Unsplash

You’ve probably benefited from third-party libraries that someone else has created. Third-party libraries might save you a lot of time when building an app because they’re plug and play. Third-party libraries also have different names from dependencies.

The most common and widely used dependency manager is CocoaPods. CocoaPods has over 82,000+ libraries and counting, and is being used in over three million apps.

You can choose to create either a public or a private third-party library. A public library can used by others who could then suggest improvements to your code. …


Leverage UIBezierPath to draw awesome shapes in iOS apps

Multi-colored circles
Multi-colored circles
Photo by Mel Poole on Unsplash.

There are many different libraries out there that can help you create either a full circle, half-circle, or even a pizza slice shape.

But what if the process of making it wasn’t so difficult? Would you still consider using a third-party SDK? The benefit of making your own is the flexibility to make whatever you want.

Sometimes, third-party SDKs just don’t offer what you need and you have to continue your search for another one. That’s a lot of time wasted if it doesn’t fit into your business requirements.

Well, I hope this one will give you what you need.

Prerequisites

Kelvin Tan

I write about SwiftUI, UIKit, Swift, RxSwift at www.daddycoding.com.

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