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
  • What's new in CloudKit

    CloudKit provides a secure, convenient, and reliable cloud database for your apps — and it's only getting better. Discover how you can unravel your threads with support for async/await and convenience API additions. We'll also show you how to encourage collaboration between people using your app through sharing entire record zones of data, and explore how to adopt CloudKit features like encrypted values and help protect sensitive data within your app.

    To get the most out of this session, we recommend being familiar with CloudKit and its operations on containers, as well as a basic understanding of record and data types.

    Recursos

    • CloudKit Samples: Encryption
    • CloudKit Samples: Private Database
    • CloudKit
      • Vídeo HD
      • Vídeo SD

    Vídeos relacionados

    WWDC23

    • What’s new in privacy

    WWDC22

    • Enhance collaboration experiences with Messages

    WWDC21

    • Build apps that share data through CloudKit and Core Data
    • Meet async/await in Swift
    • Meet CloudKit Console

    Tech Talks

    • Get the most out of CloudKit Sharing
  • Buscar neste vídeo...
    • 3:34 - CloudKit: Existing convenience API

      // Sample code using existing Convenience API
      
      /// Delete the last person record.
      /// - Parameter completionHandler: An optional handler to process completion `success` or `failure`.
      func deleteLastPerson(completionHandler: ((Result<Void, Error>) -> Void)? = nil) {
          database.delete(withRecordID: lastPersonRecordId) { recordId, error in
              if let recordId = recordId {
                  os_log("Record with ID \(recordId.recordName) was deleted.")
              }
              if let error = error {
                  self.reportError(error)
                  // If there is a completion handler, pass along the error here.
                  completionHandler?(.failure(error))
              } else {
                  // If there is a completion handler, like during tests, call it back now.
                  completionHandler?(.success(()))
              }
          }
      }
    • 4:04 - CloudKit: Async convenience API

      // Sample code updated to CloudKit Async API
      
      /// Delete the last person record.
      func deleteLastPerson() async throws {
          do {
              let recordId = try await database.deleteRecord(with: lastPersonRecordId)
              os_log("Record with ID \(recordId.recordName) was deleted.")
          } catch {
              self.reportError(error)
              throw error
          }
      }
    • 5:39 - CloudKit: Existing completion blocks

      // Error reporting in CKFetchRecordsOperation
      
      extension CKFetchRecordsOperation {
          var perRecordCompletionBlock: ((CKRecord?, CKRecord.ID?, Error?) -> Void)?
      
          var fetchRecordsCompletionBlock: (([CKRecord.ID : CKRecord]?, Error?) -> Void)?
      }
      
      
      fetchRecordsOp.perRecordCompletionBlock = { record, recordID, error in
          // error is CKError.unknownItem. 
      }
      
      fetchRecordsOp.fetchRecordsCompletionBlock = { recordsByRecordID, operationError in
          // operationError is CKError.partialFailure.
          // operationError.partialErrorsByItemID[missingRecordID] is CKError.unknownItem.
      }
    • 6:35 - CloudKit: Result type completion blocks

      // Error reporting in CKFetchRecordsOperation
      
      extension CKFetchRecordsOperation {
          var perRecordResultBlock: ((CKRecord.ID, Result<CKRecord, Error>) -> Void)?
      
          var fetchRecordsResultBlock: ((Result<Void, Error>) -> Void)?
      }
      
      
      fetchRecordsOp.perRecordResultBlock = { recordID, result in
          // result is .failure(CKError.unknownItem) or .success(record).
      }
      
      fetchRecordsOp.fetchRecordsResultBlock = { result in
          // result is .success.
      }
    • 9:14 - CloudKit: Delete single item

      // Single item delete
      
      func deleteLastPerson() async throws {
          do {
              let recordId = try await database.deleteRecord(with: lastPersonRecordId)
              os_log("Record with ID \(recordId.recordName) was deleted.")
          } catch {
              self.reportError(error)
              throw error
          }
      }
    • 9:37 - CloudKit: Delete batch

      // Batched modifications
      
      func deleteLastPeople() async throws {
          do {
              let recordIds = [lastPersonRecordId, penultimatePersonRecordId]
              let (_, deleteResults) = try await database.modifyRecords(deleting: recordIds)
              for (recordId, deleteResult) in deleteResults {
                  switch deleteResult {
                  case .failure(let error):
                      self.reportError(error, itemId: recordId)
                  case .success:
                      os_log("Record with ID \(recordId.recordName) was deleted.")
                  }
              }
          } catch let operationError {
              self.reportError(operationError)
              throw operationError
          }
      }
    • 13:43 - CloudKit: Encrypted values

      extension CKRecord {
          @NSCopying open var encryptedValues: CKRecordKeyValueSetting { get }
      }
    • 14:29 - CloudKit: Using encrypted values

      // Device 1: Encrypt data before calling CKModifyRecordsOperation.
      
      myRecord.encryptedValues["encryptedStringField"] = "Sensitive value"
      
      // Device 2: Decrypt data after calling CKFetchRecordsOperation.
      
      let decryptedString = myRecord.encryptedValues["encryptedStringField"] as? String
    • 16:35 - CloudKit: Account status

      open func accountStatus(completionHandler: @escaping (CKAccountStatus, Error?) -> Void)
    • 16:46 - CloudKit: CKAccountStatus

      public enum CKAccountStatus : Int {
          case couldNotDetermine
          case available
          case restricted
          case noAccount
          case temporarilyUnavailable
      }
    • 21:10 - CloudKit: Setup a record hierarchy

      // Share a record hierarchy
      
      
      let zone = CKRecordZone(zoneName: "MyZone")
      
      // Save zone...
      
      let fileRecordA = CKRecord(recordType: "File", recordID: CKRecord.ID(zoneID: zone.zoneID))
      let fileRecordB = CKRecord(recordType: "File", recordID: CKRecord.ID(zoneID: zone.zoneID))
      let folderRecord = CKRecord(recordType: "Folder", recordID: CKRecord.ID(zoneID: zone.zoneID))
      
      fileRecordA.setParent(folderRecord)
      fileRecordB.setParent(folderRecord)
      
      // Save records...
    • 21:41 - CloudKit: Record Hierarchy, Share

      // Share a record hierarchy
      
      
      let share = CKShare(rootRecord: folderRecord)
      
      do {
          let (saveResults, _) = try await database.modifyRecords(saving: [folderRecord, share])
          for (recordID, saveResult) in saveResults { 
              // Handle per-record result.
          }
      } catch let operationError { 
          // Handle operation error.
      }
    • 22:51 - CloudKit: Share a Record Zone

      // Share a record zone
      
      
      let zone = CKRecordZone(zoneName: "MyZone")
      
      // Save zone... 
      
      let share = CKShare(recordZoneID: zone.zoneID)
      
      do {
          let (saveResults, _) = try await database.modifyRecords(saving: [share])
          for (recordID, saveResult) in saveResults { 
              // Handle per-record result.
          }
      } catch let operationError { 
          // Handle operation error.
      }

Developer Footer

  • Vídeos
  • WWDC21
  • What's new in CloudKit
  • 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