UserDefaults within apps are used to store data related to user configurations. It’s an easily accessible data store for saving states, statistics, and other app-related data. Launch arguments are passed to the application on launch and can be used to alter the application for debugging purposes. It’s often used by Apple to allow developers to …
How-to use Diffable Data Sources with Core Data
Diffable Data Sources were introduced at WWDC 2019 as a replacement for UICollectionViewDataSource and UITableViewDataSource. The API is available on iOS 13 and up and makes it easy to set up lists of data in which changes are managed through so-called snapshots. The Core Data team added new delegate methods to the NSFetchedResultsControllerDelegate to make …
Diffable Data Sources Adoption with Ease
Diffable Data Sources were introduced at WWDC 2019 and are available since iOS 13. They’re a replacement of the good old UICollectionViewDataSource and UITableViewDataSource protocols and make it easier to migrate changes in your data views. Diffable Data Sources come with a few benefits over using the classic data source approach and are the preferred …
Persistent History Tracking in Core Data
WWDC 2017 introduced a new concept available from iOS 11 which is persistent history tracking. It’s Apple’s answer for merging changes that come from several targets like app extensions. Whenever you change something in your Core Data database from your Share Extension, a transaction is written which can be merged into any of your other …
withAnimation completion callback with animatable modifiers
SwiftUI is great when it comes down to animations as it does a lot for you with methods like withAnimation and animation(…). You can simply pass in the things you’d like it to animate and SwiftUI will make sure your views move smoothly from one state to another. Sometimes, however, you’d like to have the …
Write-Ahead Logging (WAL) disabled to force commits in Core Data
Write-Ahead Logging is the default journaling mode for Core Data SQLite stores since iOS 7 and OS X Mavericks. Journaling in Core Data is best explained as the way data transactions are saved into the underlying SQLite store. The WAL mode is significantly faster in most scenarios compared to the previous default “rollback” journal mode …
How to combine text weights in SwiftUI
Combining multiple text weights in SwiftUI might not look straight forward at first. If you’re used to using UIKit you were probably looking into support for NSAttributedString in which you could apply different text styles for certain ranges. SwiftUI makes it possible to combine different text styles with the built-in plus (+) operator implementation. Multiple …
Adding a closure as a target to UIButton and other controls in Swift
The target-action pattern is used in combination with user interface controls as a callback to a user event. Whenever a button is pressed on a target, its action will be called. The fact that the method is not defined close to the control definition is sometimes seen as a downside and reason for a lot …
Launch screens in Xcode: All the options explained
Launch screens appear when your app starts up and give the user the impression that your app is fast and responsive. After your app is loaded it will be replaced with your app’s first screen after which the user can start using your app. Xcode creates a storyboard by default which you can use to …
ValueTransformer in Core Data explained: Storing absolute URLs
ValueTransformers in Core Data are a powerful way of transforming values before they get inserted into the database and before they get read. They’re set up in an abstract class which handles the value transformations from one representation to another. They’re often used as a way to store values that aren’t supported by default. Core …