# NSAttributedString class reference

anoq@vip.cybercity.dk
richard@brainstorm.co.uk
Generated at 2025-09-10 09:16:48 +0000
1997-2022 Free Software Foundation, Inc.
Software documentation for the NSAttributedString class
Foundation/NSAttributedString.h
NSCoding
NSCopying
NSMutableCopying
A string in which name-value pairs represented by an NSDictionary may be associated to ranges of characters. Used for text rendering by the GUI/AppKit framework, in which fonts, sizes, etc. are stored under standard attributes in the dictionaries.
attribute:
attributeName
atIndex:
index
effectiveRange:
aRange
Returns value for given attribute at index, and, if effectiveRange is non-nil, this gets filled with a range over which this value holds. This may not be the maximum range, depending on the implementation.
attribute:
attributeName
atIndex:
index
longestEffectiveRange:
aRange
inRange:
rangeLimit
Returns value for given attribute at index, and, if longestEffectiveRange is non-nil, this gets filled with the range over which the attribute applies, clipped to rangeLimit.
attributedSubstringFromRange:
aRange
Returns substring with attribute information.
attributesAtIndex:
index
effectiveRange:
aRange
Returns attributes and values at index, and, if effectiveRange is non-nil, this gets filled with a range over which these attributes and values still hold. This may not be the maximum range, depending on the implementation.
attributesAtIndex:
index
longestEffectiveRange:
aRange
inRange:
rangeLimit
Returns attributes and values at index, and, if longestEffectiveRange is non-nil, this gets filled with the range over which the attribute-value set is the same as at index, clipped to rangeLimit.
initWithAttributedString:
attributedString
Initialize to copy of attributedString.
initWithString:
aString
Initialize to aString with no attributes.
initWithString:
aString
attributes:
attributes
Initialize to aString with given attributes applying over full range of string.
isEqualToAttributedString:
otherString
Returns whether all characters and attributes are equal between this string and otherString.
length
Return length of the underlying string.
string
Returns the string content of the receiver.
NB. this is actually a proxy to the internal content (which may change) so if you need an immutable instance you should copy the returned value, not just retain it.
Return the underlying string, stripped of attributes.
Software documentation for the NSMutableAttributedString class
Foundation/NSAttributedString.h
Mutable version of NSAttributedString .
addAttribute:
name
value:
value
range:
aRange
Adds attribute applying to given range.
addAttributes:
attributes
range:
aRange
Add attributes to apply over given range.
appendAttributedString:
attributedString
Appends attributed string to end of this one, preserving attributes.
beginEditing
Call before executing a collection of changes, for optimization.
deleteCharactersInRange:
aRange
Removes characters and attributes applying to them.
endEditing
Call after executing a collection of changes, for optimization.
insertAttributedString:
attributedString
atIndex:
index
Inserts attributed string within this one, preserving attributes.
mutableString
Returns mutable version of the underlying string.
removeAttribute:
name
range:
aRange
Removes given attribute from aRange.
replaceCharactersInRange:
aRange
withAttributedString:
attributedString
Replaces substring and attributes.
replaceCharactersInRange:
aRange
withString:
aString
Replaces substring; replacement is granted attributes equal to those of the first character of the portion replaced.
setAttributedString:
attributedString
Replaces entire contents (so this object can be reused).
setAttributes:
attributes
range:
aRange
Sets attributes to apply over range, replacing any previous attributes.