---
title: "attributes(at:effectiveRange:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nsattributedstring/attributes(at:effectiverange:)"
---

# attributes(at:effectiveRange:)

Returns the attributes for the character at the specified index.

## Declaration

```swift
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 doc://com.apple.foundation/documentation/Foundation/NSAttributedString/attributes(at:longestEffectiveRange:in:). If you don’t need this value, pass NULL.

## Return Value

Return Value The attributes for the character at index.

## Discussion

Discussion Raises an rangeException if index lies beyond the end of the receiver’s characters. For a list of possible attributes, see NSAttributedString.Key.

## See Also

### Getting attributes for a range of text

- [attributes(at:longestEffectiveRange:in:)](foundation/nsattributedstring/attributes(at:longesteffectiverange:in:).md)
- [attribute(_:at:effectiveRange:)](foundation/nsattributedstring/attribute(_:at:effectiverange:).md)
- [attribute(_:at:longestEffectiveRange:in:)](foundation/nsattributedstring/attribute(_:at:longesteffectiverange:in:).md)
- [enumerateAttribute(_:in:options:using:)](foundation/nsattributedstring/enumerateattribute(_:in:options:using:).md)
- [enumerateAttributes(in:options:using:)](foundation/nsattributedstring/enumerateattributes(in:options:using:).md)
- [NSAttributedString.EnumerationOptions](foundation/nsattributedstring/enumerationoptions.md)
