How to find memory leaks?

The common way to find memory leaks is by using Xcode Instruments. All you need is the following: Open Xcode Instruments Choose Leaks option Select Simulator where you are going to test your application Select your installed application When you finish preparation, you can start immediate recoding and check application for leaks. To do that, you need to open Simulator and try some cases that could cause memory leaks. After you spend some time trying different scenarios, you can see that Instruments found Leaked Objects....

December 20, 2023 · 1 min · Dmytro Chumakov

ARC in Swift

What is ARC? Swift uses Automatic Reference Counting (ARC) to track and manage your app’s memory usage. In most cases, this means that memory management “just works” in Swift, and you don’t need to think about memory management yourself. ARC automatically frees up the memory used by class instances when those instances are no longer needed. - Apple ARC In Action In this example, we assign an instance to the reference1 property....

December 17, 2023 · 5 min · Dmytro Chumakov

What is closure in Swift language?

Introduction In this article, I’m going to briefly explain what closure is. Closures is self-conitained blocks of funcionality that can be passed around and used in your code. — Apple Expression: { (params) -> return value in statements } @escaping When closure is marked as escaping, it will outlive or leave the scope you passed. func response(_ completionHandler: @escaping(Result) -> Void) { completionHandler(.success) } @nonescaping By default, closures are nonescaping, meaning closure will no longer exist in memory after complete execution in the scope you have passed it to....

December 10, 2023 · 1 min · Dmytro Chumakov

What is “reference type” in Swift?

Introduction In Swift, classes, closures, and actors all reference types. ‘Reference type’ is instance that shares a single copy of data. Assigning a reference type to a constant or variable, or passing it into a function or method, it is always a reference to a shared instance that is assigned or passed in. Example You can pass your property value by sharing the same address in memory. // Reference type example class Storage { var data = “data-example” } var storage = Storage() print("\(storage....

December 3, 2023 · 1 min · Dmytro Chumakov

Let’s talk about Composable Architecture

Introduction The Composable Architecture (TCA) uses a unidirectional data flow (UDF). UDF is a design pattern where data and events move consistently and predictably. In UDF, data can only be transferred to other application parts in one way. In TCA, the only way to mutate the state is by sending actions to a runtime store. The runtime store holds the entire app’s business logic and mutates the state inside. UDF can reduce data inconsistencies because of the single source of truth for the application....

August 11, 2023 · 1 min · Dmytro Chumakov