View in English

  • Apple Developer
    • Get Started

    Explore Get Started

    • Overview
    • Learn
    • Apple Developer Program

    Stay Updated

    • Latest News
    • Hello Developer
    • Platforms

    Explore Platforms

    • Apple Platforms
    • iOS
    • iPadOS
    • macOS
    • tvOS
    • visionOS
    • watchOS
    • App Store

    Featured

    • Design
    • Distribution
    • Games
    • Accessories
    • Web
    • Home
    • CarPlay
    • Technologies

    Explore Technologies

    • Overview
    • Xcode
    • Swift
    • SwiftUI

    Featured

    • Accessibility
    • App Intents
    • Apple Intelligence
    • Games
    • Machine Learning & AI
    • Security
    • Xcode Cloud
    • Community

    Explore Community

    • Overview
    • Meet with Apple events
    • Community-driven events
    • Developer Forums
    • Open Source

    Featured

    • WWDC
    • Swift Student Challenge
    • Developer Stories
    • App Store Awards
    • Apple Design Awards
    • Apple Developer Centers
    • Documentation

    Explore Documentation

    • Documentation Library
    • Technology Overviews
    • Sample Code
    • Human Interface Guidelines
    • Videos

    Release Notes

    • Featured Updates
    • iOS
    • iPadOS
    • macOS
    • watchOS
    • visionOS
    • tvOS
    • Xcode
    • Downloads

    Explore Downloads

    • All Downloads
    • Operating Systems
    • Applications
    • Design Resources

    Featured

    • Xcode
    • TestFlight
    • Fonts
    • SF Symbols
    • Icon Composer
    • Support

    Explore Support

    • Overview
    • Help Guides
    • Developer Forums
    • Feedback Assistant
    • Contact Us

    Featured

    • Account Help
    • App Review Guidelines
    • App Store Connect Help
    • Upcoming Requirements
    • Agreements and Guidelines
    • System Status
  • Quick Links

    • Events
    • News
    • Forums
    • Sample Code
    • Videos
 

Vídeos

Abrir menu Fechar menu
  • Coleções
  • Todos os vídeos
  • Sobre

Mais vídeos

  • Sobre
  • Código
  • Data Essentials in SwiftUI

    Data is a complex part of any app, but SwiftUI makes it easy to ensure a smooth, data-driven experience from prototyping to production. Discover @State and @Binding, two powerful tools that can preserve and seamlessly update your Source of Truth. We'll also show you how ObservableObject lets you connect your views to your data model. Learn about some tricky challenges and cool new ways to solve them — directly from the experts!

    To get the most out of this session, you should be familiar with SwiftUI. Watch “App essentials in SwiftUI” and "Introduction to SwiftUI"

    Recursos

    • Model data
      • Vídeo HD
      • Vídeo SD

    Vídeos relacionados

    WWDC22

    • Use SwiftUI with UIKit

    WWDC21

    • Demystify SwiftUI
    • Discover concurrency in SwiftUI

    WWDC20

    • App essentials in SwiftUI
    • Introduction to SwiftUI
    • Stacks, Grids, and Outlines in SwiftUI
    • Structure your app for SwiftUI previews
    • What's new in SwiftUI
  • Buscar neste vídeo...
    • 2:09 - BookCard

      struct BookCard : View {
          let book: Book
          let progress: Double
      
          var body: some View {
              HStack {
                  Cover(book.coverName)
                  VStack(alignment: .leading) {
                      TitleText(book.title)
                      AuthorText(book.author)
                  }
                  Spacer()
                  RingProgressView(value: progress)              
              }
          }
      }
    • 3:35 - EditorConfig

      struct EditorConfig {
          var isEditorPresented = false
          var note = ""
          var progress: Double = 0
          mutating func present(initialProgress: Double) {
              progress = initialProgress
              note = ""
              isEditorPresented = true
          }
      }
      struct BookView: View {
          @State private var editorConfig = EditorConfig()
          func presentEditor() { editorConfig.present(…) }
          var body: some View {
              …
              Button(action: presentEditor) { … }
              …
          }
      }
    • 5:59 - ProgressEditor

      struct EditorConfig {
          var isEditorPresented = false
          var note = ""
          var progress: Double = 0
      }
      struct BookView: View {
          @State private var editorConfig = EditorConfig()
          var body: some View {
              …
              ProgressEditor(editorConfig: $editorConfig)
              …
          }
      }
      
      struct ProgressEditor: View {
          @Binding var editorConfig: EditorConfig
          …
              TextEditor($editorConfig.note)
          …
      }
    • 13:15 - CurrentlyReading

      /// The current reading progress for a specific book.
      class CurrentlyReading: ObservableObject {
          let book: Book
          @Published var progress: ReadingProgress
      
          // …
      }
      
      struct ReadingProgress {
          struct Entry : Identifiable {
              let id: UUID
              let progress: Double
              let time: Date
              let note: String?
          }
      
          var entries: [Entry]
      }
    • 15:36 - BookView

      struct BookView: View {
          @ObservedObject var currentlyReading: CurrentlyReading
      
          var body: some View {
              VStack {
                  BookCard(
                      currentlyReading: currentlyReading)
      
                  //…
      
                  ProgressDetailsList(
                      progress: currentlyReading.progress)
              }
          }
      }
    • 17:50 - CurrentlyReading with isFinished

      class CurrentlyReading: ObservableObject {
          let book: Book
          @Published var progress = ReadingProgress()
          @Published var isFinished = false
      
          var currentProgress: Double {
              isFinished ? 1.0 : progress.progress
          }
      }
    • 18:21 - BookView with Toggle

      struct BookView: View {
          @ObservedObject var currentlyReading: CurrentlyReading
      
          var body: some View {
              VStack {
                  BookCard(
                      currentlyReading: currentlyReading)
      
                  HStack {
                      Button(action: presentEditor) { /* … */ }
                          .disabled(currentlyReading.isFinished)
      
                      Toggle(
                          isOn: $currentlyReading.isFinished
                      ) {
                          Label(
                              "I'm Done",
                              systemImage: "checkmark.circle.fill")
                      }
                  }
                  //…
              }
          }
      }
    • 19:58 - CoverImageLoader

      class CoverImageLoader: ObservableObject {
          @Published public private(set) var image: Image? = nil
      
          func load(_ name: String) {
              // …
          }
      
          func cancel() {
              // …
          }
      
          deinit {
              cancel()
          }
      }
    • 20:20 - BookCoverView

      struct BookCoverView: View {
          @StateObject var loader = CoverImageLoader()
      
          var coverName: String
          var size: CGFloat
      
          var body: some View {
              CoverImage(loader.image, size: size)
                  .onAppear { loader.load(coverName) }
          }
      }
    • 25:36 - ReadingListViewer (Bad)

      struct ReadingListViewer: View {
          var body: some View {
              NavigationView {
                  ReadingList()
                  Placeholder()
              }
          }
      }
      
      struct ReadingList: View {
          @ObservedObject var store = ReadingListStore()
      
          var body: some View {
              // ...
          }
      }
    • 26:39 - ReadingListViewer (Good)

      struct ReadingListViewer: View {
          var body: some View {
              NavigationView {
                  ReadingList()
                  Placeholder()
              }
          }
      }
      
      struct ReadingList: View {
          @StateObject var store = ReadingListStore()
      
          var body: some View {
              // ...
          }
      }
    • 30:52 - App-wide Source of Truth

      @main
      struct BookClubApp: App {
          @StateObject private var store = ReadingListStore()
      
          var body: some Scene {
              WindowGroup {
                  ReadingListViewer(store: store)
              }
          }
      }
    • 32:43 - SceneStorage

      struct ReadingListViewer: View {
          @SceneStorage("selection") var selection: String?
      
          var body: some View {
              NavigationView {
                  ReadingList(selection: $selection)
                  BookDetailPlaceholder()
              }
          }
      }
    • 33:49 - AppStorage

      struct BookClubSettings: View {
          @AppStorage("updateArtwork") private var updateArtwork = true
          @AppStorage("syncProgress") private var syncProgress = true
      
          var body: some View {
              Form {
                  Toggle(isOn: $updateArtwork) {
                      //...
                  }
      
                  Toggle(isOn: $syncProgress) {
                      //...
                  }
              }
          }
      }

Developer Footer

  • Vídeos
  • WWDC20
  • Data Essentials in SwiftUI
  • Open Menu Close Menu
    • iOS
    • iPadOS
    • macOS
    • tvOS
    • visionOS
    • watchOS
    • App Store
    Open Menu Close Menu
    • Swift
    • SwiftUI
    • Swift Playground
    • TestFlight
    • Xcode
    • Xcode Cloud
    • Icon Composer
    • SF Symbols
    Open Menu Close Menu
    • Accessibility
    • Accessories
    • Apple Intelligence
    • Audio & Video
    • Augmented Reality
    • Business
    • Design
    • Distribution
    • Education
    • Games
    • Health & Fitness
    • In-App Purchase
    • Localization
    • Maps & Location
    • Machine Learning & AI
    • Security
    • Safari & Web
    Open Menu Close Menu
    • Documentation
    • Downloads
    • Sample Code
    • Videos
    Open Menu Close Menu
    • Help Guides & Articles
    • Contact Us
    • Forums
    • Feedback & Bug Reporting
    • System Status
    Open Menu Close Menu
    • Apple Developer
    • App Store Connect
    • Certificates, IDs, & Profiles
    • Feedback Assistant
    Open Menu Close Menu
    • Apple Developer Program
    • Apple Developer Enterprise Program
    • App Store Small Business Program
    • MFi Program
    • Mini Apps Partner Program
    • News Partner Program
    • Video Partner Program
    • Security Bounty Program
    • Security Research Device Program
    Open Menu Close Menu
    • Meet with Apple
    • Apple Developer Centers
    • App Store Awards
    • Apple Design Awards
    • Apple Developer Academies
    • WWDC
    Read the latest news.
    Get the Apple Developer app.
    Copyright © 2026 Apple Inc. All rights reserved.
    Terms of Use Privacy Policy Agreements and Guidelines