iOS 17 @Observable and the Observation Framework
<p>WWDC 2023 introduced us to the new iOS-17<code>@Observable</code> property wrapper along with a cleaned-up <code>@State</code> that now supersedes the previous <code>@State</code> <code>@ObservedObject</code>, <code>@StateObject</code>. This is fantastic — it’s always been a source of confusion for those starting on SwiftUI and a source of bugs (with various recommendations on what to use and when).</p>
<p>All this feels like it’s gone and we are left with the simple choice of <code>@Environment</code>, <code>@State</code>, and <code>@Bindable</code> with clean usage (in order: app-wide, view-wide, and binding to a parent). Love it!</p>
<p>Let’s take a quick look at how this works. You’ll notice that tapping the button triggers a screen refresh to display the new value of <code>myString</code>. You also no longer need <code>@Published</code>. Fantastic!</p>
<p><a href="https://betterprogramming.pub/ios-17-observable-and-the-observation-framework-152deaf8fc5e"><strong>Read More</strong></a></p>