<!--
{
  "availability" : [
    "macOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSAttributedString/range(of:at:)-1wrcp",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSAttributedString(im)rangeOfTextBlock:atIndex:"
  },
  "title" : "range(of:at:)"
}
-->

# range(of:at:)

Returns the range of the individual text block that contains the specified location.

```
func range(of block: NSTextBlock, at location: Int) -> NSRange
```

## Parameters

`block`

The text block.

`location`

The location in the text block.

## Return Value

The range of the text block containing the location.

---

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)