Skip to content

Data Essential in SwiftUI - 2020

Published:
2 min read

Reference: Data Essential in SwiftUI - 2020

State and Binding

State-Binding

Performance Considerations

Avoid Repeated Heap allocation problem by using @StateObject appropriately.

Repeated Heap Allocation

StateObject Example

ObservableObject

Observable Object Publish

ObservableObject can be used to provide a single source of truth through view / app hierarchy, either as a single Instance (one object) or multiple instances.

Observable Object

Three Ways to Subscribe to ObservableObjects

There are 3 ways that View can subscribe to changes of @ObservableObjects:

Data Life-cycle

Data Lifetime