View in English

  • Apple Developer
    • 今すぐ始める

    「今すぐ始める」を詳しく見る

    • 概要
    • 学ぶ
    • Apple Developer Program

    最新情報

    • 最新ニュース
    • Hello Developer
    • プラットフォーム

    プラットフォームを詳しく見る

    • Appleプラットフォーム
    • iOS
    • iPadOS
    • macOS
    • tvOS
    • visionOS
    • watchOS
    • App Store

    特集

    • デザイン
    • 配信
    • ゲーム
    • アクセサリ
    • Web
    • Home
    • CarPlay
    • テクノロジー

    テクノロジーを詳しく見る

    • 概要
    • Xcode
    • Swift
    • SwiftUI

    特集

    • アクセシビリティ
    • App Intent
    • Apple Intelligence
    • ゲーム
    • 機械学習とAI
    • セキュリティ
    • Xcode Cloud
    • コミュニティ

    コミュニティを詳しく見る

    • 概要
    • 「Appleに相談」イベント
    • コミュニティによるイベント
    • デベロッパフォーラム
    • オープンソース

    特集

    • WWDC
    • Swift Student Challenge
    • デベロッパストーリー
    • App Store Awards
    • Apple Design Awards
    • Apple Developer Center
    • ドキュメント

    ドキュメントを詳しく見る

    • ドキュメントライブラリ
    • テクノロジー概要
    • サンプルコード
    • ヒューマンインターフェイスガイドライン
    • ビデオ

    リリースノート

    • 注目のアップデート
    • iOS
    • iPadOS
    • macOS
    • watchOS
    • visionOS
    • tvOS
    • Xcode
    • ダウンロード

    ダウンロードを詳しく見る

    • すべてのダウンロード
    • オペレーティングシステム
    • アプリ
    • デザインリソース

    特集

    • Xcode
    • TestFlight
    • フォント
    • SF Symbols
    • Icon Composer
    • サポート

    サポートを詳しく見る

    • 概要
    • ヘルプガイド
    • デベロッパフォーラム
    • フィードバックアシスタント
    • お問い合わせ

    特集

    • アカウントヘルプ
    • App Reviewガイドライン
    • App Store Connectヘルプ
    • 近日導入予定の要件
    • 契約およびガイドライン
    • システムステータス
  • クイックリンク

    • イベント
    • ニュース
    • Forum
    • サンプルコード
    • ビデオ
 

ビデオ

メニューを開く メニューを閉じる
  • コレクション
  • すべてのビデオ
  • 利用方法

その他のビデオ

  • 概要
  • Summary
  • コード
  • SwiftDataの新機能

    SwiftDataの最新の機能強化を紹介します。Codableを使ってカスタム型やサードパーティの型を永続化する方法や、取得したデータをSwiftUIアプリのセクションにグループ化する方法を確認します。また、ModelResultsObserverやHistoryObserverを使用して、あらゆる場所でのデータストアの変更をオブザーブする方法も学びます。この方法により、パワフルな状態オブジェクトの利用、デリゲートベースのアーキテクチャとの統合、モデルの更新に対して正確に反応できる柔軟性を実現できます。

    関連する章

    • 0:00 - Introduction
    • 0:53 - Sectioning your fetches
    • 2:56 - Using custom types
    • 6:26 - Observing data stores with ResultsObserver
    • 9:41 - Observing history with HistoryObserver
    • 12:20 - Next steps

    リソース

    • SwiftData
    • Adopting SwiftData for a Core Data app
      • HDビデオ
      • SDビデオ

    関連ビデオ

    WWDC26

    • Code Along:SwiftDataによる永続性の追加

    WWDC24

    • SwiftDataの履歴機能によるモデル変更のトラッキング
  • このビデオを検索
    • 0:01 - Sectioned fetching

      // Sectioned fetching
      
      struct TripListView: View {   
          @Query(sort: \Trip.startDate,
                 sectionBy: \.destination)
          var trips: [Trip]
      
          var body: some View: {
              List(selection: $selection) {
                  ForEach(_trips.sections) {section in
                      Section(section.id) {
                          ForEach(trips) {trip in
                              TripListItem(trip: trip)
                          }
                     }
                  }
              }
          }
      }
    • 4:59 - Using Codable

      // Using Codable
      
      import SwiftData
      
      @Model class Trip {
      
          struct Location: Codable {
              var latitude: Double
              var longitude: Double
          }
      
          var name: String
          var destination: String
      
          var startDate: Date
          var endDate: Date
      
          var location: Location?
          @Attribute(.codable) var mapItemIdentifier: MKMapItem.Identifier?
      }
    • 8:20 - // Use observation to update map bounds

      // Use observation to update map bounds
      
      @Observable @MainActor final class MapCameraController {
          private let modelResultsObserver: ModelResultsObserver<Trip>
          var bounds: MapCameraBounds?
          private var token: ObservationTracking.Token?
      
          init(modelContext: ModelContext) throws {
              modelResultsObserver = try ModelResultsObserver<Trip>(modelContext: modelContext)
      
              token = withContinuousObservation(options: [.didSet]) {[weak self], event in
                  self?.bounds = self?.calculateBounds(trips: modelResultsObserver.results)
             }
          }
      
          private func calculateBounds(trips: [Trip]) -> MapCameraBounds? { / * */ }
      }
    • 8:21 - // Using HistoryObserver to sync with a server

      // Using HistoryObserver to sync with a server
      
      @SyncActor final class ServerSync {
          private let observer: HistoryObserver
          private var token: ObservationTracking.Token?
      
          func start() throws {
              self.observer = try HistoryObserver(authors: ["App"], modelContainer: modelContainer)
              token = withContinuousObservation(options: .didSet) {[weak self] _ in
                  _ = self?.observer.eventCounter
                  self?.processChanges()
              }
          }
      
          private func processChanges() {
              // Fetch and process history transactions
          }
      }
    • 0:00 - Introduction
    • What's new in SwiftData for Apple's 2027 releases, with a preview of the agenda: sectioning fetches, using custom types, and observing data stores.

    • 0:53 - Sectioning your fetches
    • Use @Query's new sectionBy: parameter to group results by a key path. Access the underlying query via the underscore-prefixed name to iterate sections, each with an id and a collection of models — demonstrated by grouping trips by destination in SampleTrips.

    • 2:56 - Using custom types
    • Store types SwiftData can't model natively — like MKMapItem.Identifier — by marking properties with @Attribute(.codable). Treat codable as an escape hatch for external types, not types you own; modeling your own types as @Model or supported value types unlocks filtering, sorting, and migration.

    • 6:26 - Observing data stores with ResultsObserver
    • The new ResultsObserver brings Query-style fetching to non-SwiftUI code. Combine it with withContinuousObservation(didSet:) to react to model changes anywhere in your app — shown updating map camera bounds as trips change.

    • 9:41 - Observing history with HistoryObserver
    • HistoryObserver exposes a single observable eventCounter that ticks when new persistent-history transactions arrive. Pair it with ModelContext.fetchHistory() to filter by model type or transaction author — ideal for syncing changes to an external server.

    • 12:20 - Next steps
    • Recap: section your fetches, adopt codable types, react to data changes with ResultsObserver, and observe history with HistoryObserver.

Developer Footer

  • ビデオ
  • WWDC26
  • SwiftDataの新機能
  • メニューを開く メニューを閉じる
    • iOS
    • iPadOS
    • macOS
    • tvOS
    • visionOS
    • watchOS
    Open Menu Close Menu
    • Swift
    • SwiftUI
    • Swift Playground
    • TestFlight
    • Xcode
    • Xcode Cloud
    • SF Symbols
    メニューを開く メニューを閉じる
    • アクセシビリティ
    • アクセサリ
    • Apple Intelligence
    • App Extension
    • App Store
    • オーディオとビデオ(英語)
    • 拡張現実
    • デザイン
    • 配信
    • 教育
    • フォント(英語)
    • ゲーム
    • ヘルスケアとフィットネス
    • アプリ内課金
    • ローカリゼーション
    • マップと位置情報
    • 機械学習とAI
    • オープンソース(英語)
    • セキュリティ
    • SafariとWeb(英語)
    メニューを開く メニューを閉じる
    • 英語ドキュメント(完全版)
    • 日本語ドキュメント(一部トピック)
    • チュートリアル
    • ダウンロード
    • フォーラム(英語)
    • ビデオ
    Open Menu Close Menu
    • サポートドキュメント
    • お問い合わせ
    • バグ報告
    • システム状況(英語)
    メニューを開く メニューを閉じる
    • Apple Developer
    • App Store Connect
    • Certificates, IDs, & Profiles(英語)
    • フィードバックアシスタント
    メニューを開く メニューを閉じる
    • 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 Research Device Program(英語)
    Open Menu Close Menu
    • Appleに相談
    • Apple Developer Center
    • App Store Awards(英語)
    • Apple Design Awards
    • Apple Developer Academy(英語)
    • WWDC
    最新ニュースを読む。
    Apple Developerアプリを入手する。
    Copyright © 2026 Apple Inc. All rights reserved.
    利用規約 プライバシーポリシー 契約とガイドライン