Fresh Swift
  • About
  • Tags
Fresh Swift

#state


A guide to SwiftUI’s state management system

SwiftUI includes several property wrappers that allow us to declare exactly how data is observed and mutated by views. In this post from John Sundell, he takes a closer look at SwiftUI's overall state management system and provides concrete examples of when we might use each of the related property wrappers.

Posted on July 17, 2020

#swiftui  #state 

The difference between @StateObject, @EnvironmentObject, and @ObservedObject in SwiftUI

SwiftUI implements it's data flow management types, such as State, Binding, and ObservedObject, as property wrappers. In this post, Majid explains the difference between some of these property wrappers, including the new StateObject property wrapper which is available in iOS 14

Posted on July 12, 2020

#swiftui  #state  #ios14 

An iOS alert view with a text field and a “smart” OK button

This is a very interesting post from Ole Bergmann, in which he demonstrates an approach to keeping an object alive by intentionally capturing it in a closure. Not an approach I had previously considered.

Posted on August 20, 2018

#iOS  #state  #closure  #lifetime 

Design Patterns in Swift: State Pattern

This post from Dejan Agostini describes what the State pattern is, and shows us how to implement it in Swift using a simple example.

Posted on May 21, 2018

#state  #design pattern 

Reactive iOS Programming: Lightweight State Containers in Swift

In this post, Tyler Tillage looks at an approach to managing app state using state containers. He starts by building a state container which wraps a state value, and then demonstrates how we can use this container to listen for state changes. It’s a nice approach, and something I can see myself adopting in my own projects.

Posted on July 27, 2017

#state 

Modelling state in Swift

Dealing with state is hard, error prone, and unavoidable. In this post, John Sundell looks at some of the commonly used techniques we can apply when dealing with state in Swift. I think the first two points - having a single source of truth, and making states exclusive - are key.

Posted on July 12, 2017

#state  #enum 

 •  2021  •  Fresh Swift

Hugo v0.81.0 powered  •  Theme by Beautiful Jekyll adapted to Beautiful Hugo