Instance Method

attribute:atIndex:longestEffectiveRange:inRange:

Returns the value for the attribute with a given name of the character at a given index, and by reference the range over which the attribute applies.

Declaration

- (id)attribute:(NSAttributedStringKey)attrName atIndex:(NSUInteger)location longestEffectiveRange:(NSRangePointer)range inRange:(NSRange)rangeLimit;

Parameters

attributeName

The name of an attribute.

index

The index at which to test for attributeName.

aRange

If non-NULL:

  • If the named attribute exists at index, upon return aRange contains the full range over which the value of the named attribute is the same as that at index, clipped to rangeLimit.

  • If the named attribute does not exist at index, upon return aRange contains the full range over which the attribute does not exist, clipped to rangeLimit.

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

rangeLimit

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

Return Value

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

Discussion

Raises an NSRangeException if index or any part of rangeLimit lies beyond the end of the receiver’s characters.

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

For a list of possible attributes, see Character Attributes.

See Also

Retrieving Attribute Information

- attributesAtIndex:effectiveRange:

Returns the attributes for the character at a given index.

- attributesAtIndex:longestEffectiveRange:inRange:

Returns the attributes for the character at a given index, and by reference the range over which the attributes apply.

- attribute:atIndex:effectiveRange:

Returns the value for an attribute with a given name of the character at a given index, and by reference the range over which the attribute applies.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software