Contents

temporaryAttribute(_:atCharacterIndex:longestEffectiveRange:in:)

Returns the value for the temporary attribute of a character, and the maximum range it applies to.

Declaration

func temporaryAttribute(_ attrName: NSAttributedString.Key, atCharacterIndex location: Int, longestEffectiveRange range: NSRangePointer?, in rangeLimit: NSRange) -> Any?

Parameters

  • attrName:

    The name of a temporary 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 location, on output, contains the maximum range over which the named attribute’s value applies, clipped to rangeLimit.

    • If the named attribute does not exist at location, on output, contains the maximum range over which the attribute does not exist.

    If you don’t need this value, pass NULL.

  • rangeLimit:

    The range over which to search for continuous presence of attrName. This value must not exceed the bounds of the receiver.

Return Value

The value for the attribute named attrName of the character at location, or nil if there is no such attribute.

Discussion

If you don’t need the longest effective range, it’s far more efficient to use the temporaryAttribute(_:atCharacterIndex:effectiveRange:) method to retrieve the attribute value.

See Also

Managing temporary attribute support