<!--
{
  "availability" : [
    "macOS: 12.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSTextRange/contains(_:)-7hvi0",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSTextRange(im)containsLocation:"
  },
  "title" : "contains(_:)"
}
-->

# contains(_:)

Determines if the text location you specify is in the current text range.

```
func contains(_ location: any NSTextLocation) -> Bool
```

## Parameters

`location`

An [`NSTextLocation`](/documentation/AppKit/NSTextLocation).

## Return Value

Returns `true` if the location is in the range otherwise `false` .

---

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)