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
  • Meet Transferable

    Meet Transferable: a model-layer protocol that allows for effortless support for sharing, drag and drop, copy/paste, and other features in your app.

    We'll explore how you can use the API for common use cases, and take advantage of advanced features to customize the behavior. We'll also share how you can optimize for memory efficiency when dealing with large amounts of data. Whether you're extending your models to share with other applications as strings or images or creating custom declared data types, Transferable can help you facilitate a great experience in your app.

    Recursos

    • ShareLink
      • Vídeo HD
      • Vídeo SD

    Vídeos relacionados

    WWDC22

    • Build a productivity app for Apple Watch
    • Enhance collaboration experiences with Messages
    • Integrate your custom collaboration app with Messages
    • What's new in SwiftUI

    Tech Talks

    • Uniform Type Identifiers — a reintroduction
  • Buscar neste vídeo...
    • 4:36 - Declaring a custom content type

      import UniformTypeIdentifiers
      
      // also declare the content type in the Info.plist
      extension UTType {
          static var profile: UTType = UTType(exportedAs: "com.example.profile")
      }
    • 5:10 - PasteButton interface

      import SwiftUI
      
      struct Profile {
          private var funFacts: [String] = []
          mutating func addFunFacts(_ newFunFacts: [String]) {
              funFacts.append(newFunFacts)
          }
      }
      
      struct PasteButtonView: View {
          @State var profile = Profile()
          var body: some View {
              PasteButton(payloadType: String.self) { funFacts in
                  profile.addFunFacts(funFacts)
              }
          }
      }
    • 5:19 - Drag and Drop

      import SwiftUI
      
      struct PortraitView: View {
          @State var portrait: Image
          var body: some View {
              portrait
                  .cornerRadius(8)
                  .draggable(portrait)
                  .dropDestination(payloadType: Image.self) { (images: [Image], _) in
                      if let image = images.first {
                          portrait = image
                          return true
                      }
                      return false
                  }
          }
      }
    • 5:27 - Sharing

      import SwiftUI
      
      struct Profile {
          var name: String
      }
      
      struct ProfileView: View {
          @State private var portrait: Image
          var model: Profile
      
          var body: some View {
              VStack {
                  portrait
                  Text(model.name)
              }
              .toolbar {
                  ShareLink(item: portrait, preview: SharePreview(model.name))
              }
          }
      }
    • 6:34 - Profile structure

      import Foundation
      
      struct Profile: Codable {
          var id: UUID
          var name: String
          var bio: String
          var funFacts: [String]
          var video: URL?
          var portrait: URL?
      }
    • 7:31 - CodableRepresentation

      import CoreTransferable
      import UniformTypeIdentifiers
      
      struct Profile: Codable {
          var id: UUID
          var name: String
          var bio: String
          var funFacts: [String]
          var video: URL?
          var portrait: URL?
      }
      
      extension Profile: Codable, Transferable {
          static var transferRepresentation: some TransferRepresentation {
              CodableRepresentation(contentType: .profile)
          }
      }
      
      // also declare the content type in the Info.plist
      extension UTType {
          static var profile: UTType = UTType(exportedAs: "com.example.profile")
      }
    • 8:30 - DataRepresentation

      import CoreTransferable
      import UniformTypeIdentifiers
      
      struct ProfilesArchive {
          init(csvData: Data) throws { }
          func convertToCSV() throws -> Data { Data() }
      }
      
      extension ProfilesArchive: Transferable {
          static var transferRepresentation: some TransferRepresentation {
              DataRepresentation(contentType: .commaSeparatedText) { archive in
                  try archive.convertToCSV()
              } importing: { data in
                  try ProfilesArchive(csvData: data)
              }
          }
      }
    • 9:14 - FileRepresentation

      import CoreTransferable
      
      struct Video: Transferable {
          let file: URL
          static var transferRepresentation: some TransferRepresentation {
              FileRepresentation(contentType: .mpeg4Movie) { 
                  SentTransferredFile($0.file)
              } importing: { received in
                  let destination = try Self.copyVideoFile(source: received.file)
                  return Self.init(file: destination)
              }
          }
        
          static func copyVideoFile(source: URL) throws -> URL {
              let moviesDirectory = try FileManager.default.url(
                  for: .moviesDirectory, in: .userDomainMask,
                  appropriateFor: nil, create: true
              )
              var destination = moviesDirectory.appendingPathComponent(
                  source.lastPathComponent, isDirectory: false)
              if FileManager.default.fileExists(atPath: destination.path) {
                  let pathExtension = destination.pathExtension
                  var fileName = destination.deletingPathExtension().lastPathComponent
                  fileName += "_\(UUID().uuidString)"
                  destination = destination
                      .deletingLastPathComponent()
                      .appendingPathComponent(fileName)
                      .appendingPathExtension(pathExtension)
              }
              try FileManager.default.copyItem(at: source, to: destination)
              return destination
          }
      }
    • 10:05 - ProxyRepresentation

      import CoreTransferable
      import UniformTypeIdentifiers
      
      struct Profile: Codable {
          var id: UUID
          var name: String
          var bio: String
          var funFacts: [String]
          var video: URL?
          var portrait: URL?
      }
      
      extension Profile: Transferable {
          static var transferRepresentation: some TransferRepresentation {
              CodableRepresentation(contentType: .profile)
              ProxyRepresentation(exporting: \.name)
          }
      }
      
      // also declare the content type in the Info.plist
      extension UTType {
          static var profile: UTType = UTType(exportedAs: "com.example.profile")
      }
    • 11:34 - Proxy and file representations

      import CoreTransferable
      
      struct Video: Transferable {
          let file: URL
          static var transferRepresentation: some TransferRepresentation {
              FileRepresentation(contentType: .mpeg4Movie) { SentTransferredFile($0.file) }
                 importing: { received in
                     let copy = try Self.copyVideoFile(source: received.file)
                     return Self.init(file: copy) }
              ProxyRepresentation(exporting: \.file)
        }
      
          static func copyVideoFile(source: URL) throws -> URL {
              let moviesDirectory = try FileManager.default.url(
                  for: .moviesDirectory, in: .userDomainMask,
                  appropriateFor: nil, create: true
              )
              var destination = moviesDirectory.appendingPathComponent(
                  source.lastPathComponent, isDirectory: false)
              if FileManager.default.fileExists(atPath: destination.path) {
                  let pathExtension = destination.pathExtension
                  var fileName = destination.deletingPathExtension().lastPathComponent
                  fileName += "_\(UUID().uuidString)"
                  destination = destination
                      .deletingLastPathComponent()
                      .appendingPathComponent(fileName)
                      .appendingPathExtension(pathExtension)
              }
              try FileManager.default.copyItem(at: source, to: destination)
              return destination
          }
      }
    • 12:57 - Exporting condition

      import CoreTransferable
      import UniformTypeIdentifiers
      
      struct ProfilesArchive {
          var supportsCSV: Bool { true }
          init(csvData: Data) throws {  }
          func convertToCSV() throws -> Data { Data() }
      }
      
      extension ProfilesArchive: Transferable {
          static var transferRepresentation: some TransferRepresentation {
              DataRepresentation(contentType: .commaSeparatedText) { archive in
                  try archive.convertToCSV()
              } importing: { data in
                  try Self(csvData: data)
              }
              .exportingCondition { $0.supportsCSV }
          }
      }

Developer Footer

  • Vídeos
  • WWDC22
  • Meet Transferable
  • 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