This article is originally published at https://swiftsenpai.com on March 26, 2021.
If you are like me, have been using a diffable data source section snapshot for quite some time, I am sure you will notice that the code to construct a section snapshot is actually quite difficult to reason about. The
append(_:to:) API doesn't really show us the hierarchical data structure it represents.
With the release of result builders in Swift 5.4, it makes me wonder is it possible to create a domain-specific language (DSL) that can help us to:
When developing an iOS app, at times we need to store sensitive data (password, access token, secret key, etc) locally. For junior developers, the first thing that comes to mind will be storing it using
However, as we all know, storing sensitive data using
UserDefaults is a very bad idea, it is because data stored using
UserDefaults is not encrypted and extremely insecure.
In order to securely store sensitive data locally, we should use the keychain service provided by Apple. …
As a developer, very often we need to deal with complex algorithms that take hours or even days to develop. Thanks to Swift’s higher-order functions such as
filter, etc., some of those complex algorithms can now easily be solved with just a few lines of code.
In this article, I would like to show you five algorithms that used to be difficult to implement but are now extremely easy to achieve thanks to the higher-order functions in Swift.
Throughout this article, I will be using the following
students array as the model object so that you can have…
In October 2020, I published an article that discusses how to reload a table and collection view cell when using a diffable data source. The article shows you how to use two totally different approaches when reloading cells with reference- and value-type items.
As a recap, for reference-type items, we can leverage the snapshot’s
reloadItems(_:) method to reload the specified items. For value-type items,
reloadItems(_:) will not work. We will have to manually replace the updated items within the snapshot.
I was always confused by why Apple makes such a simple task so complicated. At WWDC21, Apple showed us another…
If I asked iOS developers which LLDB command they use the most, they would probably answer
po. But did you know that you can actually define your own custom LLDB command using purely Swift code?
In this article, I will show you what it takes to create your own LLDB command. Here is what I will be covering:
Let’s get started!
In order to add a custom LLDB command, we must leverage the
command alias LLDB command. …
In iOS 14, Apple shows their love to SwiftUI by giving it automatic keyboard avoidance. It’s turned on by default, meaning all your SwiftUI views can get this awesome feature automatically once you build your apps for iOS 14.
Unfortunately, for whatever reason, Apple does not make this available for UIKit despite the fact that it is one of the features most requested by developers around the world.
In this article, I would like to show you how to enable automatic keyboard avoidance in a view controller using a trick that I recently discovered. …
This is a story about me spending a whole hour just to remove rounded corners from an
UIImageView. I’m sure my fellow developers will have had a similar experience at some point — spending an unreasonable amount of time to complete a simple task. This is one of those stories.
This story does not involve any extraordinary programming knowledge, but I do like to use it to bring out some of my views regarding the attitude that developers should have when solving problems. …
Back in June 2020, during WWDC20, Apple announced that, starting with iOS 14, developers would need permission from users before tracking them. In other words, apps won’t be able to access the device’s IDFA (Identifier for Advertisers) unless it is authorized.
In September 2020, Apple delayed this change so that developers and publishers have more time to adapt to it.
Earlier this month (April 2021), Apple made a public announcement, asking all developers to get ready for
AppTrackingTransparency, indicating that Apple will fully enforce the tracking authorization in their upcoming iOS public release (iOS 14.5).
As a developer, our job…
When Apple introduced limited photo access in iOS 14, some iOS developers were not so happy about it. It seemed like Apple was trying to make developers’ lives harder. Any apps (old or new) that want to support iOS 14 or higher will have to handle this extra permission status.
Meanwhile, from the user’s perspective, it is a very welcome change. Users can now have more control over the privacy of their photos, limiting the number of photos an app can access.
With this new permission status, the way to handle photo library permissions in iOS 14 is very different…
This article is originally published at https://swiftsenpai.com on March 10, 2021.
Result builders (formerly known as function builders) is a new feature introduced in Swift 5.4, it is the technology that empowers
ViewBuilder in SwiftUI. With the release of Xcode 12.5 (currently in beta stage), Apple has made it officially available for the developers, allowing us to create our own custom result builders for various kinds of use cases.
In this article, I would like to share with you the basic concept of result builders, how it works, and how you can use it to create your own custom result…