Two Hours Without a Smartphone

Fatbobman's Swift Weekly #061

Dec 9, 2024

Last week, one of my belongings needed repair. The shop informed me it would take about two hours, so I set off by car to a shopping mall with only my laptop in tow. It wasn’t until I handed over my i...

Model Inheritance in Core Data

One of Core Data's outstanding features is its ability to allow developers to declare data models in a manner closer to object-oriented programming without worrying about the underlying storage implementation details. Within this framework, model inheritance is a particularly important mechanism. This article delves into the core concepts of model inheritance, including Parent Entity, Sub Entity, and Abstract Entity. We will analyze their advantages and disadvantages and explore how to achieve similar effects without directly using these features.

Dec 4, 2024
Typefully: Say Goodbye to the Hassles of Social Media Posting

As social media channels continue to expand, internet users often find themselves managing multiple social accounts without even realizing it. For content creators and corporate account managers, the preparatory work required to post content across various social platforms is becoming increasingly cumbersome. Over the past month, I started using Typefully to centrally manage and publish content on multiple social platforms. Now, I'd like to share my experience.

Nov 27, 2024
Intentional Design or Technical Flaw? The Anomaly of onChange in SwiftUI Multi-Layer Navigation

SwiftUI provides the onChange modifier, allowing developers to listen for changes in specific values within a view and execute corresponding actions when those values change. Intuitively, as long as a view is part of the currently visible branch of the view tree (active), the corresponding closure should be triggered when the observed value changes. However, in certain navigation scenarios, the onChange modifier seems to become "selectively deaf," inexplicably remaining silent even when the observed value changes. Is this a carefully designed feature by Apple, or a long-hidden code defect? This article aims to unveil this phenomenon and provide necessary caution to developers.

Using Transactions Instead of Save in SwiftData and Core Data

Ensuring data consistency and integrity is crucial in data persistence operations. The SwiftData framework introduces the `transaction` method in `ModelContext`, providing developers with a more elegant way to organize and manage data operations. This article explores how to use the concept of transactions to build more reliable and efficient persistence operations.

Nov 13, 2024
Understanding SwiftUI's View Update Mechanism: Starting from a TimelineView Update Issue

In SwiftUI, the automatic view update mechanism allows us to easily build responsive user interfaces. However, sometimes views may not update as we expect. This article explores SwiftUI's view update mechanism through a seemingly simple but representative TimelineView update issue.

Mastering Data Tracking and Notifications in Core Data and SwiftData

Core Data and SwiftData, as powerful persistence frameworks in the Apple ecosystem, not only provide declarative data listening tools like @FetchRequest and @Query, but also have a complete set of data tracking and notification mechanisms built-in. Understanding and mastering these mechanisms is crucial for building robust data-driven applications. This article will take you through multi-layered solutions—from simple custom notifications to the powerful Persistent History Tracking and SwiftData History—to help you handle various complex data synchronization scenarios.

Starting with Project Refactoring: Sharing Five Swift Modules

Recently, I embarked on the reconstruction of an app that had not received significant updates for four years. During the process, I extracted some functional modules and shared them as open-source projects. This article provides a brief introduction to the libraries I have open-sourced over the past two months.

Oct 23, 2024
Comprehensive Guide to Mastering KeyPath in Swift

In the world of Swift, KeyPath is a powerful yet often underestimated feature. Many developers use it inadvertently in their daily programming without fully realizing its potential and importance. This article aims to delve deeply into the functional characteristics of KeyPath, revealing its unique charm in Swift programming, and helping you transform it into a powerful assistant in your development process.

Weekly Swift & SwiftUI insights, delivered every Monday night. Join developers worldwide.
Easy unsubscribe, zero spam guaranteed