Up

NSAttributedString class reference

Authors

ANOQ of the sun (anoq@vip.cybercity.dk)
Richard Frith-Macdonald (richard@brainstorm.co.uk)

Version: 1.42

Date: 2004/10/09 15:40:23

Copyright: (C) 1997,1999 Free Software Foundation, Inc.


Contents -

  1. Software documentation for the NSAttributedString class
  2. Software documentation for the NSMutableAttributedString class

Software documentation for the NSAttributedString class

NSAttributedString : NSObject

Declared in:
Foundation/NSAttributedString.h
Conforms to:
NSCoding
NSCopying
NSMutableCopying
Standards:

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.

Method summary

attribute: atIndex: effectiveRange: 

- (id) attribute: (NSString*)attributeName atIndex: (unsigned int)index effectiveRange: (NSRange*)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: atIndex: longestEffectiveRange: inRange: 

- (id) attribute: (NSString*)attributeName atIndex: (unsigned int)index longestEffectiveRange: (NSRange*)aRange inRange: (NSRange)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: 

- (NSAttributedString*) attributedSubstringFromRange: (NSRange)aRange;

Returns substring with attribute information.


attributedSubstringWithRange: 

- (NSAttributedString*) attributedSubstringWithRange: (NSRange)aRange;

Synonym for -attributedSubstringFromRange: .


attributesAtIndex: effectiveRange: 

- (NSDictionary*) attributesAtIndex: (unsigned int)index effectiveRange: (NSRange*)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: longestEffectiveRange: inRange: 

- (NSDictionary*) attributesAtIndex: (unsigned int)index longestEffectiveRange: (NSRange*)aRange inRange: (NSRange)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: 

- (id) initWithAttributedString: (NSAttributedString*)attributedString;

Initialize to copy of attributedString.


initWithString: 

- (id) initWithString: (NSString*)aString;

Initialize to aString with no attributes.


initWithString: attributes: 

- (id) initWithString: (NSString*)aString attributes: (NSDictionary*)attributes;

Initialize to aString with given attributes applying over full range of string.


isEqualToAttributedString: 

- (BOOL) isEqualToAttributedString: (NSAttributedString*)otherString;

Returns whether all characters and attributes are equal between this string and otherString.


length 

- (unsigned int) length;

Return length of the underlying string.


string 

- (NSString*) string;

Return the underlying string, stripped of attributes.


Software documentation for the NSMutableAttributedString class

NSMutableAttributedString : NSAttributedString

Declared in:
Foundation/NSAttributedString.h
Standards:

Mutable version of NSAttributedString .

Method summary

addAttribute: value: range: 

- (void) addAttribute: (NSString*)name value: (id)value range: (NSRange)aRange;

Adds attribute applying to given range.


addAttributes: range: 

- (void) addAttributes: (NSDictionary*)attributes range: (NSRange)aRange;

Add attributes to apply over given range.


appendAttributedString: 

- (void) appendAttributedString: (NSAttributedString*)attributedString;

Appends attributed string to end of this one, preserving attributes.


beginEditing 

- (void) beginEditing;

Call before executing a collection of changes, for optimization.


deleteCharactersInRange: 

- (void) deleteCharactersInRange: (NSRange)aRange;

Removes characters and attributes applying to them.


endEditing 

- (void) endEditing;

Call after executing a collection of changes, for optimization.


insertAttributedString: atIndex: 

- (void) insertAttributedString: (NSAttributedString*)attributedString atIndex: (unsigned int)index;

Inserts attributed string within this one, preserving attributes.


mutableString 

- (NSMutableString*) mutableString;

Returns mutable version of the underlying string.


removeAttribute: range: 

- (void) removeAttribute: (NSString*)name range: (NSRange)aRange;

Removes given attribute from aRange.


replaceCharactersInRange: withAttributedString: 

- (void) replaceCharactersInRange: (NSRange)aRange withAttributedString: (NSAttributedString*)attributedString;

Replaces substring and attributes.


replaceCharactersInRange: withString: 

- (void) replaceCharactersInRange: (NSRange)aRange withString: (NSString*)aString;

Replaces substring; replacement is granted attributes equal to those of the first character of the portion replaced.


setAttributedString: 

- (void) setAttributedString: (NSAttributedString*)attributedString;

Replaces entire contents (so this object can be reused).


setAttributes: range: 

- (void) setAttributes: (NSDictionary*)attributes range: (NSRange)aRange;

Sets attributes to apply over range, replacing any previous attributes.



Up