Posts for: #Swift

Delegate Pattern in Swift

Lately, I’ve been writing a lot about UIKit and I noticed I haven’t covered the delegate pattern. This pattern is not exclusive to UIKit but it’s quite used in this framework. In this post, we’ll dive into the Delegation Pattern, a fundamental design pattern in iOS development that helps in creating a well-structured codebase. What is the Delegation Pattern? The Delegation Pattern is a design pattern where one object (the delegator) hands off (or delegates) some of its responsibilities to another object (the delegate).
Read more

An Introductory Example of Deeplinking in iOS

Hello everyone. Lately, I’ve been experimenting with deep links and SwiftUI. In the realm of iOS development, deep linking emerges as a powerful and indispensable tool, offering developers the means to seamlessly connect users to specific content or features within their applications. At its core, deep linking allows for the precise navigation to a particular section of an app, rather than merely launching the app’s home screen. Understanding the fundamentals of iOS deep linking is pivotal for enhancing user experience, promoting user engagement, and, ultimately, unlocking the full potential of your mobile applications.
Read more

A Simple Full-Stack iOS App Example

One of the benefits of using Swift is its excellent performance and low memory footprint. This is a key point when doing backend programming. The future of Swift in Linux looks promising. With Swift 5.9, there will be better error logging, and Apple is developing a new open-source cross-platform testing framework with swift-testing that will replace XCTest and works on Linux too. Let’s hope this encourages more backend systems to be written in Swift.
Read more

Replacing Elements in a String

One of the most common problems we face when working with strings is modifying certain characters in the string. This problem can be easily solved with the use of regular expressions (regex). Before Swift 5.7 If you can’t uae the newest Swift you can achieve this by using the method replacingOccurrences(of:with:options). Here is an example of its use: let s = "12abc34" let t = ss.replacingOccurrences( of: "[a-z]", // regex with: "", options: .
Read more

Swift copy-on-write

To understand what copy-on-write means we need to delve into Swift’s type classification. Objects in Swift can be divided into two type groups: value types and reference types. The main difference between the two is how they are managed in memory. Theoretically, Value types create a new copy on memory each time they are assigned to a new variable, conversely reference types share the same reference amongst all variables. What is copy-on-write?
Read more