As a reactive framework, SwiftUI offers a plethora of property wrappers that can serve as the Source of Truth, each with its unique purpose and characteristics. Simultaneously, effectively utilizing the various tools provided by SwiftUI to manage data flow presents a significant challenge for every developer.
Overview of Property Wrappers
- Exploring Key Property Wrappers in SwiftUI: @State, @Binding, @StateObject, @ObservedObject, @EnvironmentObject, and @Environment
In this article, we will explore several property wrappers that are frequently used and crucial in SwiftUI development. This article aims to provide an overview of the main functions and usage considerations of these property wrappers, rather than a detailed usage guide.
- 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.
- 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.
- 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.
Mastering Property Wrappers
- SwiftUI’s StateObject and ObservedObject: The Key Differences
This article will introduce the similarities, differences, principles, and precautions between StateObject and ObservedObject.
- SwiftUI 2.0 —— Research on @StateObject
WWDC 20 just concluded, and in the past week, Apple has brought huge surprises to developers. Due to the plethora of new features, it takes some time to digest them. I first chose the content I am most interested in for some simple research and discussion. This article first briefly discusses the new property wrapper @StateObject provided by SwiftUI.
- @State Research in SwiftUI
This article aims to explore and analyze the implementation and operational characteristics of @State in SwiftUI. It concludes with an idea and example for extending the functionality of @State. Readers should have a basic understanding of reactive programming in SwiftUI.
- ObservableObject Research - Expressing Love is Not Easy
This article mainly explores in SwiftUI, using a Single Source of Truth development pattern, whether ObservableObject is the best choice. It examines if it's possible to try new approaches without significantly altering the existing design philosophy to improve response efficiency. Finally, a method is provided that still uses the single source of truth design concept but completely abandons the use of ObservableObject.
- Mastering @AppStorage in SwiftUI
This article explores how to use @AppStorage in a graceful, efficient, and secure manner within SwiftUI, addressing the current pain points encountered with @AppStorage usage, all without resorting to third-party libraries.
- Going Beyond @Published:Empowering Custom Property Wrappers
This article explains how to make a property wrapper notify the class that wraps it of any changes, similar to Published and compliant with the ObservedObject protocol. - SwiftUI - Swift
Architecture
- UserDefaults and Observation in SwiftUI: How to Achieve Precise Responsiveness
In SwiftUI, Apple's @AppStorage property wrapper greatly simplifies the process for developers to respond to and modify UserDefaults content within views. However, with the introduction of the Observation framework, new challenges have arisen—Apple has yet to provide a UserDefaults management solution for Observation. This article will explore how to efficiently and conveniently manage data in UserDefaults under the Observation framework and propose a complete and practical solution.
- A Deep Dive Into Observation: A New Way to Boost SwiftUI Performance
This article will comprehensively and thoroughly explore the Observation framework in a Q&A format, including its reasons for creation, usage methods, workings, and precautions.
- The Composable Architecture (TCA)
The Composable Architecture (TCA) is a SwiftUI framework that provides state and side effect management, testing and dependency injection. This article describes TCA's benefits, features, changes, learning, performance, and resources.
- Rebuilding SwiftUI's Redux-like State Container with Async-Await
This article explains how to refactor SwiftUI's state container code using the Async/Await feature in Swift 5.5
- Building Cross-Platform SwiftUI Apps
This article is based on my presentation at the "SwiftUI Technology Salon (Beijing Station)" on April 20, 2023, and is organized from memory.