Sitemap

Member-only story

SwiftUI: Binding

Learn about Binding in SwiftUI

4 min readMay 20, 2025

--

Press enter or click to view image in full size

Let me take you to a small, fictitious app named LyricLoop. This app lets users create and share loops of their favorite lyrics from throwback hits. The UI is clean, the interactions are slick but underneath it all, there’s a small, unsung hero named @Binding, pulling the strings behind each user interaction.

In SwiftUI, @State creates a local source of truth. But what if that truth needs to be shared? Like when a user toggles a “Public Loop” setting in the Edit screen, and the Main Profile screen needs to reflect that change immediately.

Enter @Binding

Press enter or click to view image in full size

This LoopSettingsView doesn’t own the isPublic state. It borrows it. Like borrowing a vinyl from your friend’s collection but changing the song on your record player, and it changes for your friend too.

Now let’s look at where this borrowed record came from:

Press enter or click to view image in full size

The EditLoopView holds the actual state using @State. It then passes that state as a binding using…

--

--

Stanley Miller 
Stanley Miller 

Written by Stanley Miller 

iOS Developer. Author. Fan of the interesting. Written 100+ Swift/SwiftUI articles.