Up

NSAttributedString class reference

Authors

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

Version: 33595

Date: 2011-07-21 02:23:08 +0100 (Thu, 21 Jul 2011)

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
Availability: MacOS-X 10.0.0

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: (NSUInteger)index effectiveRange: (NSRange*)aRange;
Availability: MacOS-X 10.0.0

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: (NSUInteger)index longestEffectiveRange: (NSRange*)aRange inRange: (NSRange)rangeLimit;
Availability: MacOS-X 10.0.0

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;
Availability: MacOS-X 10.0.0

Returns substring with attribute information.

attributesAtIndex: effectiveRange: 

- (NSDictionary*) attributesAtIndex: (NSUInteger)index effectiveRange: (NSRange*)aRange;
Availability: MacOS-X 10.0.0

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: (NSUInteger)index longestEffectiveRange: (NSRange*)aRange inRange: (NSRange)rangeLimit;
Availability: MacOS-X 10.0.0

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;
Availability: MacOS-X 10.0.0

Initialize to copy of attributedString.

initWithString: 

- (id) initWithString: (NSString*)aString;
Availability: MacOS-X 10.0.0

Initialize to aString with no attributes.

initWithString: attributes: 

- (id) initWithString: (NSString*)aString attributes: (NSDictionary*)attributes;
Availability: MacOS-X 10.0.0

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

isEqualToAttributedString: 

- (BOOL) isEqualToAttributedString: (NSAttributedString*)otherString;
Availability: MacOS-X 10.0.0

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

length 

- (NSUInteger) length;
Availability: MacOS-X 10.0.0

Return length of the underlying string.

string 

- (NSString*) string;
Availability: MacOS-X 10.0.0

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 yu should copy the returned value, not jhust retain it.
Return the underlying string, stripped of attributes.

Software documentation for the NSMutableAttributedString class

NSMutableAttributedString : NSAttributedString

Declared in:
Foundation/NSAttributedString.h
Availability: MacOS-X 10.0.0

Mutable version of NSAttributedString .
Method summary

addAttribute: value: range: 

- (void) addAttribute: (NSString*)name value: (id)value range: (NSRange)aRange;
Availability: MacOS-X 10.0.0

Adds attribute applying to given range.

addAttributes: range: 

- (void) addAttributes: (NSDictionary*)attributes range: (NSRange)aRange;
Availability: MacOS-X 10.0.0

Add attributes to apply over given range.

appendAttributedString: 

- (void) appendAttributedString: (NSAttributedString*)attributedString;
Availability: MacOS-X 10.0.0

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

beginEditing 

- (void) beginEditing;
Availability: MacOS-X 10.0.0

An empty method provided for subclasses to override.
Call before executing a collection of changes, for optimization.

deleteCharactersInRange: 

- (void) deleteCharactersInRange: (NSRange)aRange;
Availability: MacOS-X 10.0.0

Removes characters and attributes applying to them.

endEditing 

- (void) endEditing;
Availability: MacOS-X 10.0.0

An empty method provided for subclasses to override.
Call after executing a collection of changes, for optimization.

insertAttributedString: atIndex: 

- (void) insertAttributedString: (NSAttributedString*)attributedString atIndex: (NSUInteger)index;
Availability: MacOS-X 10.0.0

Inserts attributed string within this one, preserving attributes.

mutableString 

- (NSMutableString*) mutableString;
Availability: MacOS-X 10.0.0

Returns mutable version of the underlying string.

removeAttribute: range: 

- (void) removeAttribute: (NSString*)name range: (NSRange)aRange;
Availability: MacOS-X 10.0.0

Removes given attribute from aRange.

replaceCharactersInRange: withAttributedString: 

- (void) replaceCharactersInRange: (NSRange)aRange withAttributedString: (NSAttributedString*)attributedString;
Availability: MacOS-X 10.0.0

Replaces substring and attributes.

replaceCharactersInRange: withString: 

- (void) replaceCharactersInRange: (NSRange)aRange withString: (NSString*)aString;
Availability: MacOS-X 10.0.0

Subclasses must override this method.
Replaces substring; replacement is granted attributes equal to those of the first character of the portion replaced.

setAttributedString: 

- (void) setAttributedString: (NSAttributedString*)attributedString;
Availability: MacOS-X 10.0.0

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

setAttributes: range: 

- (void) setAttributes: (NSDictionary*)attributes range: (NSRange)aRange;
Availability: MacOS-X 10.0.0

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


Up