Home

071

Building Android Apps with Swift - #071

Building Android Apps with Swift

Feb 18, 2025 Issue #071
The Swift community has launched the Swift on Android Community Workgroup to advance Swift development on Android. This ...
Explore Full Issue
From Host to Serverless: A Blog Architecture Migration Journey
Feb 19, 2025 #Web

In the past month and a half, I’ve made a series of adjustments to my blog, covering areas such as the publishing mechanism, code architecture, and layout design. These changes have not only enhanced the performance and user experience of the blog but also made content maintenance and updates more efficient. This article provides a brief overview of the key changes.


Mastering SwiftUI Scrolling: Implementing Custom Paging
Feb 12, 2025 #SwiftUI

Starting with iOS 17, SwiftUI introduced scrollTargetBehavior, enabling developers to control scrolling behavior with greater precision. Whether it's aligning views at rest or implementing custom paging effects, scrollTargetBehavior offers robust support. More importantly, developers can create custom ScrollTargetBehavior implementations to meet specific needs. This article will walk through a real-world example, step by step, to demonstrate how to use scrollTargetBehavior and ultimately implement a custom scrolling control logic.

Why Certain View Modifiers in Swift 6 Cannot Use the @State Property
Dec 24, 2024 #SwiftUI #Swift

In Xcode 16, to improve SwiftUI's performance under Swift 6 mode, Apple made several adjustments to the SwiftUI framework's APIs to meet stricter concurrency checks. The most notable change is the comprehensive annotation of the View protocol with @MainActor. While these optimizations generally enhance the developer experience in Swift 6 mode, they also introduce some seemingly anomalous compile-time errors in specific scenarios. This article delves into why certain view modifiers cannot directly use @State properties and provides corresponding solutions.


Traps and Countermeasures for Abnormal onAppear Calls in SwiftUI
Dec 18, 2024 #SwiftUI

onAppear is an extremely crucial lifecycle method in SwiftUI, used to inject key logic when a view is presented. Since view instances may be created and rebuilt frequently, developers often choose to prepare data and perform initialization operations within these methods. In theory, the timing of these lifecycle method calls should be predictable and consistent. However, in certain specific scenarios, onAppear may be called unexpectedly and unnecessarily. This not only can lead to performance overhead but also may cause uncontrollable changes in the application's state. This article will uncover this easily overlooked SwiftUI behavior trap and provide temporary countermeasures.


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.


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

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.


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

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.