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

标签 objective-c swift

我对 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/

相关文章:

objective-c - 如何从 NSWindow 对象创建 NSTouchBar?

iOS:具有外部参数的对象类中的 setter

iphone - UITableViewCell 编辑模式,如联系人应用

ios - 如何在 iOS 中不存在 mymail viewcontroller 的情况下点击发送邮件?

c++ - 在 XCode 中生成 getter 和 setter

json - 当使用 Alamofire 和 SwiftyJSON 从 URL 获取 JSON 时,链接返回 nil 并使我的应用程序崩溃

ios - 无法将类型 'Swift._ContiguousArrayStorage<AppName.JobsNearBy>' (0x113b1a200) 的值转换为 'AppName.JobsNearBy' (0x10e6e7e60)

xcode - 如何调整swift表达式编译超时?

ios - 欧拉角 Y 值受 X 和 Z 值的影响——如何将它们归零以获得 "truthful"y 值?

ios - Xcode 8 构建仅针对模拟器失败