Your First iOS App: Data Flow in SwiftUI

Jun 25 2026 · Swift 6, iOS 26, Xcode 26

Lesson 02: SwiftUI State

SwiftUI State

Episode complete

Play next episode

Next

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now

A key part of programming SwiftUI is state. Rather than start with the computer science definition of state, let’s go with something that might be a little more familiar: the dashboard of a car.

@State private var alertIsVisible: Bool = false
alertIsVisible = true
  .alert(
    <titleKey: ...>,
    isPresented: Binding<...>,
    actions: <...>,
    message: <...>
  )
  .alert(
    "Hello there!",
  .alert(
    "Hello there!",
    isPresented: $alertIsVisible,
    actions: <...>,
    message: <...>
  )
actions: {
  Button("Awesome!") {
    print("Alert closed")
  }
}
    message: {
      Text("This is my first alert!")
    }
  )
  .alert(
    "Hello there!",
    isPresented: $alertIsVisible,
    actions: {
      Button("Awesome!") {
        print("Alert closed")
      }
    },
    message: {
      Text("This is my first alert")
    }
  )
See forum comments
Cinema mode Download course materials from Github
Previous: Buttons & Actions Next: SwiftUI Bindings