<!--
{
  "availability" : [
    "iOS: 11.0.0 -",
    "iPadOS: 11.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.4.0 -",
    "tvOS: 11.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "PDFKit",
  "identifier" : "/documentation/PDFKit/PDFDocument/findString(_:withOptions:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "PDFKit"
    ],
    "preciseIdentifier" : "c:objc(cs)PDFDocument(im)findString:withOptions:"
  },
  "title" : "findString(_:withOptions:)"
}
-->

# findString(_:withOptions:)

Synchronously finds all instances of the specified string in the document.

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

## Discussion

Each hit gets added to an `NSArray` object as a [`PDFSelection`](/documentation/PDFKit/PDFSelection) object. If there are no hits, this method returns an empty array.

Use this method when the complete search process will be brief and when you don’t need the flexibility or control offered by [`beginFindString(_:withOptions:)`](/documentation/PDFKit/PDFDocument/beginFindString(_:withOptions:)). For options, refer to [Searching, Comparing, and Sorting Strings](https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/Strings/Articles/SearchingStrings.html#//apple_ref/doc/uid/20000149).

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)