Category: Swift

Architectural Patterns – Decorator

In this article I will present you powerful architectural pattern that I have been using it a lot called Decorator. 1. What is Decorator By definition Decorator is architectural pattern which allows us incorporating new services, behaviours to existing components when certain events occur or simply augmenting existing behaviours. Main benefit of the pattern is […]

Detect user’s country without accessing their location

Sometimes we are faced with challenge where we would like to improve user experience of our app based on where in the world or better said in which country our clients are using the application. For example if you would like to show some content (or even download in from the API on the fly), […]

Async execution of long-running operations using Swift’s Task

In this article I will try to show you how to adopt Swift’s Task which is part of new Concurrency API’s with an example where we want to execute long-running operations on background thread without changing existing implementation of the operation. Instead making adoption by changing existing code we will build reusable component which will […]

Use Swift’s ‘async’ without breaking the existing codebase

With the release of Swift 5.5 and upcoming release of Xcode 13.2 we are finally able to use new Swift Concurrency APIs. In this article I will try to show you a way how to use new APIs into the codebase where needed or even required without actually breaking or changing the existing code. Quick […]

Observing model changes using Swift’s @propertyWrapper

In this post we will take a look how can we implement alternative mechanism for observing model changes and reacting to those changes using @propertyWrapper‘s introduced in Swift 5 and make quick comparison against existing and popular approaches. First let’s take a quick overview of existing popular solutions and quickly analyse them. 1. Using ‘didSet’ […]

How to encapsulate business rules using policies

In this post we will have a look have can we encapsulate simple business rules using policies. To clear out what policy actually is and its benefits we will jump straightforward into example. Let’s say that we have application that needs our users to sign up before they can start using it. But to actually […]

A better way to handle weak properties and memory management

In this post we will have a look to alternative way how can we handle memory management without leaking implementation details in our components and using ‘weak’ properties all over our code base. Usually when we are dealing with delegation we usually tend to use weak properties for achieving our goal. I believe that this […]