<!--
{
  "availability" : [
    "iOS: 3.2.0 -",
    "iPadOS: 3.2.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.0.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSAttributedString/attributes(at:effectiveRange:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSAttributedString(im)attributesAtIndex:effectiveRange:"
  },
  "title" : "attributes(at:effectiveRange:)"
}
-->

# attributes(at:effectiveRange:)

Returns the attributes for the character at the specified index.

```
func attributes(at location: Int, effectiveRange range: NSRangePointer?) -> [NSAttributedString.Key : Any]
```

## Parameters

`location`

The index for which to return attributes. This value must lie within the bounds of the receiver.

`range`

Upon return, the range over which the attributes and values are the same as those at `index`. This range isn’t necessarily the maximum range covered, and its extent is implementation-dependent. If you need the maximum range, use [`attributes(at:longestEffectiveRange:in:)`](/documentation/Foundation/NSAttributedString/attributes(at:longestEffectiveRange:in:)). If you don’t need this value, pass `NULL`.

## Return Value

The attributes for the character at `index`.

## Discussion

Raises an [`rangeException`](/documentation/Foundation/NSExceptionName/rangeException) if `index` lies beyond the end of the receiver’s characters.

For a list of possible attributes, see [`NSAttributedString.Key`](/documentation/Foundation/NSAttributedString/Key).

---

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)