attribute(_:at:effectiveRange:)
Returns the value for an attribute with the specified name of the character at the specified index and, by reference, the range where the attribute applies.
Declaration
func attribute(_ attrName: NSAttributedString.Key, at location: Int, effectiveRange range: NSRangePointer?) -> Any?Parameters
- attrName:
The name of an attribute.
- location:
The index for which to return attributes. This value must not exceed the bounds of the receiver.
- range:
If non-
NULL:If the named attribute exists at
index, upon returnaRangecontains a range over which the named attribute’s value applies.If the named attribute does not exist at
index, upon returnaRangecontains the range over which the attribute does not exist.
The range isn’t necessarily the maximum range covered by
attributeName, and its extent is implementation-dependent. If you need the maximum range, use Attribute(_:at:longesteffectiverange:in:). If you don’t need this value, passNULL.
Return Value
The value for the attribute named attrName of the character at location, or nil if there is no such attribute.
Discussion
For a list of possible attributes, see NSAttributedString.Key.