gpt4 book ai didi

objective-c - 在 Swift 中使用 PDFKIT 搜索 PDF

转载 作者:行者123 更新时间:2023-11-28 14:40:13 25 4
gpt4 key购买 nike

我对 swift 非常陌生,所以请多多包涵。我想弄清楚如何在 PDF 文档中搜索特定字符串。我假设我需要使用 findString 函数。我只是不知道应该如何实现这些参数。我正在使用 Apple Docs.并且看不到对此的描述。

谢谢!=]

  private func loadPDF(){
guard
let url = Bundle.main.url(forResource: pdfTitle, withExtension: "pdf"),
let document = PDFDocument(url:url)
else {fatalError()}
pdfView.document = document

}

func findString(_ string: String,
withOptions options: NSString.CompareOptions = []) -> [PDFSelection]

最佳答案

要获取匹配项列表,您可以执行以下操作:

let matches = document.findString("foo", withOptions: .caseInsensitive)

关于objective-c - 在 Swift 中使用 PDFKIT 搜索 PDF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50575299/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com