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
 

Vidéos

Ouvrir le menu Fermer le menu
  • Collections
  • Toutes les vidéos
  • À propos

Plus de vidéos

  • À propos
  • Code
  • Demystify SwiftUI performance

    Learn how you can build a mental model for performance in SwiftUI and write faster, more efficient code. We'll share some of the common causes behind performance issues and help you triage hangs and hitches in SwiftUI to create more responsive views in your app.

    Chapitres

    • 0:00 - Introduction and performance feedback loop
    • 3:30 - Dependencies
    • 10:48 - Faster view updates
    • 13:24 - Identity in List and Table

    Ressources

      • Vidéo HD
      • Vidéo SD

    Vidéos connexes

    WWDC23

    • Analyze hangs with Instruments
    • Discover Observation in SwiftUI
    • Explore SwiftUI animation

    WWDC21

    • Demystify SwiftUI

    Tech Talks

    • Explore UI animation hitches and the render loop
  • Rechercher dans cette vidéo…
    • 3:59 - DogView

      struct DogView: View {
        @Environment(\.isPlayTime) private var isPlayTime
        var dog: Dog
        var body: some View {
        	Text(dog.name)
        		.font(nameFont)
        	Text(dog.breed)
        		.font(breedFont)
        		.foregroundStyle(.secondary)
        		
        	ScalableDogImage(dog)
        	
        	DogDetailView(dog)
        	
        	LetsPlayButton()
        		.disabled(dog.isTired)
        }
       }
      }
    • 4:00 - ScalableDogImage

      struct ScalableDogImage: View {
      	@State private var scaleToFill = false
      	var dog: Dog
      	
      	var body: some View {
      		dog.image
      			.resizable()
      			.aspectRatio(
      				contentMode: scaleToFill ? .fill : .fit)
      			.frame(maxHeight: scaleToFill ? 500 : nil)
      			.padding(.vertical, 16)
      			.onTapGesture {
      				withAnimation { scaleToFill.toggle() }
      			}
      	}
      }
    • 4:01 - printChanges

      expression Self._printChanges()
    • 4:02 - ScalableDogImage + printChanges

      struct ScalableDogImage: View {
      	@State private var scaleToFill = false
      	var dog: Dog
      	
      	var body: some View {
          let _ = Self._printChanges()
      		dog.image
      			.resizable()
      			.aspectRatio(
      				contentMode: scaleToFill ? .fill : .fit)
      			.frame(maxHeight: scaleToFill ? 500 : nil)
      			.padding(.vertical, 16)
      			.onTapGesture {
      				withAnimation { scaleToFill.toggle() }
      			}
      	}
      }
    • 8:46 - ScaleableDogImage

      struct ScalableDogImage: View {
      	@State private var scaleToFill = false
      	var dog: Dog
      	
      	var body: some View {
      		dog.image
      			.resizable()
      			.aspectRatio(
      				contentMode: scaleToFill ? .fill : .fit)
      			.frame(maxHeight: scaleToFill ? 500 : nil)
      			.padding(.vertical, 16)
      			.onTapGesture {
      				withAnimation { scaleToFill.toggle() }
      			}
      	}
      }
    • 8:47 - Updated DogView

      struct DogView: View {
        @Environment(\.isPlayTime) private var isPlayTime
        var dog: Dog
        var body: some View {
        	Text(dog.name)
        		.font(nameFont)
        	Text(dog.breed)
        		.font(breedFont)
        		.foregroundStyle(.secondary)
        		
        	ScalableDogImage(dog)
        	
        	DogDetailView(dog)
        	
        	LetsPlayButton()
        		.disabled(dog.isTired)
        }
       }
      }
    • 8:48 - Final DogView

      struct DogView: View {
        @Environment(\.isPlayTime) private var isPlayTime
        var dog: Dog
        var body: some View {
        	DogHeader(name: dog.name, breed: dog.breed)
        		
        	ScalableDogImage(dog.image)
        	
        	DogDetailView(dog)
        	
        	LetsPlayButton()
        		.disabled(dog.isTired)
        }
       }
      }
    • 12:22 - DogRootView and FetchModel

      struct DogRootView: View {
      	@State private var model = FetchModel()
      	
      	var body: some View {
      		DogList(model.dogs)
      	}
      }
      
      @Observable class FetchModel {
      	var dogs: [Dog]
      	
      	init() {
      		fetchDogs()
      	}
      	
      	func fetchDogs() {
      		// Takes a long time
      	}
      }
    • 12:23 - Updated DogRootView and FetchModel

      struct DogRootView: View {
      	@State private var model = FetchModel()
      	
      	var body: some View {
      		DogList(model.dogs)
      			.task { await model.fetchDogs() }
      	}
      }
      
      @Observable class FetchModel {
      	var dogs: [Dog]
      	
      	init() {}
      	
      	func fetchDogs() async {
      		// Takes a long time
      	}
      }
    • 15:12 - List

      List {
      	ForEach(dogs) {
      		DogCell(dog: $0)
      	}
      }
    • 16:08 - List Again

      List {
      	ForEach(dogs) {
      		DogCell(dog: $0)
      	}
      }
    • 17:35 - List Fixed

      List {
      	ForEach(tennisBallDogs) { dog in
      		DogCell(dog)
      	}
      }
    • 18:25 - Sectioned List

      // Sectioned example
      struct DogsByToy: View {
      	var model: DogModel
      	var body: some View {
      		List {
      			ForEach(model.dogToys) { toy in
      				Section(toy.name) {
      					ForEach(model.dogs(toy: toy)) { dog in
      						DogCell(dog)
      					}
      				}
      			}
      		}
      	}
      }
    • 19:21 - DogTable

      struct DogTable: View {
      	var dogs: [Dog]
      	var body: some View {
      		Table(of: Dog.self) {
      			// Columns
      		} rows: {
      			ForEach(dogs) { dog in
      				TableRow(dog)
      			}
      		}
      	}
      }
    • 19:22 - DogTable Brief

      struct DogTable: View {
      	var dogs: [Dog]
      	var body: some View {
      		Table(of: Dog.self) {
      			// Columns
      		} rows: {
      			ForEach(dogs)
      		}
      	}
      }
    • 20:06 - DogTable Different IDs

      struct DogTable: View {
      	var dogs: [Dog]
      	var body: some View {
      		Table(of: Dog.self) {
      			// Columns
      		} rows: {
      			ForEach(dogs) { dog in
      				TableRow(dog.bestFriend)
      			}
      		}
      	}
      }

Developer Footer

  • Vidéos
  • WWDC23
  • Demystify SwiftUI performance
  • 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