<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "macOS: -",
    "tvOS: -",
    "visionOS: -",
    "watchOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreFoundation",
  "identifier" : "/documentation/CoreFoundation/CFAttributedStringGetAttribute(_:_:_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Core Foundation"
    ],
    "preciseIdentifier" : "c:@F@CFAttributedStringGetAttribute"
  },
  "title" : "CFAttributedStringGetAttribute(_:_:_:_:)"
}
-->

# CFAttributedStringGetAttribute(_:_:_:_:)

Returns the value of a given attribute of an attributed string at a specified location.

```
func CFAttributedStringGetAttribute(_ aStr: CFAttributedString!, _ loc: CFIndex, _ attrName: CFString!, _ effectiveRange: UnsafeMutablePointer<CFRange>!) -> CFTypeRef!
```

## Parameters

`aStr`

The attributed string to examine.

`loc`

The location in `str` at which to determine the attributes. `loc` must not exceed the bounds of `str`.

`attrName`

The name of the attribute whose value you want to determine.

`effectiveRange`

If not `NULL`, upon return contains a range including `loc` over which exactly the same set of attributes apply as at `loc`.

## Return Value

The value of the specified attribute at the specified location in `str`. Ownership follows the [The Get Rule](https://developer.apple.com/library/archive/documentation/CoreFoundation/Conceptual/CFMemoryMgmt/Concepts/Ownership.html#//apple_ref/doc/uid/20001148-SW1).

## Discussion

For performance reasons, a range returned in `effectiveRange` is not necessarily the maximal range. If you need the maximum range, you should use [`CFAttributedStringGetAttributeAndLongestEffectiveRange(_:_:_:_:_:)`](/documentation/CoreFoundation/CFAttributedStringGetAttributeAndLongestEffectiveRange(_:_:_:_:_:)).

---

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)