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

# compare(_:)

Returns a comparison result that indicates the location of the destination in the document, relative to the current position.

```
func compare(_ destination: PDFDestination) -> ComparisonResult
```

## Parameters

`destination`

The destination in the document to be located.

## Return Value

A comparison result, indicating the position of the passed-in destination relative to the current position.

## Discussion

If `destination` is between the receiver’s position and the end of the document, `compare` returns `NSOrderedAscending`; if it is between the receiver’s position and the beginning of the document, `compare` returns `NSOrderedDescending`. Otherwise, if `destination` matches the receiver’s position, `compare` returns `NSOrderedSame`.

This method ignores the horizontal component of the destination point (the x value). If the destination’s vertical component (or y value) is [`PDFDestination`](/documentation/PDFKit/PDFDestination), `compare` treats the destination as if its y value is the top point on the destination page.

An exception is raised if `destination` does not have a page associated with it or if its page is associated with a document other than the receiver’s document.

---

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)