标签: core-transferable

SwiftUI ShareLink 设置文件名

我正在使用 来ShareLink共享FileDocument包含字符串的。符合FileDocument协议Transferable

这是 FileDocument 结构:

struct TransferableDocument: FileDocument, Transferable {

  static var transferRepresentation: some TransferRepresentation
  {
      DataRepresentation(exportedContentType: .text) { log in
          log.convertToData()
      }
  }

  // tell the system to support only text
  static var readableContentTypes: [UTType] = [.text]

  // by default the document is empty
  var text = ""

  // this initializer creates a empty document
  init(initialText: String = "") {
      text = initialText
  }

  // this initializer loads data that has …
Run Code Online (Sandbox Code Playgroud)

swift swiftui swiftui-sharelink core-transferable

12
推荐指数
1
解决办法
1738
查看次数