肘子的 Swift 记事本

Fatbobman's Swift Weekly #019

Beyond Code: Embrace the Shift in Mindset

Feb 20, 2024

After several months of studying SwiftData, I only recently adopted it in my project. However, I found that coding efficiency has decreased compared to using Core Data. This is not because SwiftData i...

Feb 22, 2024
How to Handle Optional Values in SwiftData Predicates

SwiftData has revamped the mechanism for creating data models, incorporating a type-safe mode for predicate creation based on model code. As a result, developers encounter numerous operations involving optional values when constructing predicates for SwiftData. This article will explore some techniques and considerations for handling optional values while building predicates.

Feb 7, 2024
Exploring Property Wrappers in SwiftUI: @UIApplicationDelegateAdaptor, @AccessibilityFocusState, @FocusedObject, @FocusedValue, and @FocusedBinding

In this article, we will explore property wrappers such as @UIApplicationDelegateAdaptor, @AccessibilityFocusState, @FocusedObject, @FocusedValue, and @FocusedBinding. These property wrappers cover various functionalities including integration across different framework lifecycles, assistive focus, and management of focused value observations.

Feb 1, 2024
Exploring SwiftUI Property Wrappers: @FetchRequest, @SectionedFetchRequest, @Query, @Namespace, @Bindable

In this article, we will explore property wrappers such as @FetchRequest, @SectionedFetchRequest, @Query, @Namespace, and @Bindable. These property wrappers encompass functionalities such as retrieving Core Data and SwiftData within views and creating namespaces in views.

Jan 25, 2024
Exploring SwiftUI Property Wrappers: @AppStorage, @SceneStorage, @FocusState, @GestureState and @ScaledMetric

In this article, we will continue to explore property wrappers in SwiftUI @AppStorage, @SceneStorage, @FocusState, @GestureState, and @ScaledMetric. These property wrappers cover various aspects including data persistence, interactive response, accessibility features, and multi-window support, providing developers with succinct and practical solutions.

Jan 18, 2024
Relationships in SwiftData: Changes and Considerations

In previous two articles, "Mastering Relationships in Core Data - Fundamentals" and "Mastering Relationships in Core Data - Practical Application", we explored in detail the concepts and techniques of relationships in Core Data. While much of this knowledge is also applicable to SwiftData, Core Data's successor, SwiftData introduces several significant changes in handling relationships. This article focuses on the changes that have occurred in the aspect of relationships within SwiftData, as well as the potential challenges and noteworthy details arising from these changes.