This class represents a string with associated attributes that
describe the styled appearance of the string.
Attributes
are stored in a dictionary. Cocoa defines several keys to identify
common attributes such as the font, foreground color, text alignment,
line spacing, and more; these keys are listed below in the constants.
This class has many methods for querying the attributes of ranges of
text within the string. For example, the method
attributesAtIndex:effectiveRange: returns a
dictionary of attributes for the character at index, and by reference
the range that the attribute applies to is returned in the second
parameter.
@interface NSAttributedString : NSObject <NSCoding, NSCopying, NSMutableCopying>
|
// Initializers |
- (id)initWithAttributedString:(NSAttributedString *)attrStr;
|
- (id)initWithHTML:(NSData *)data baseURL:(NSURL *)base documentAttributes:(NSDictionary **)dict;
|
- (id)initWithHTML:(NSData *)data documentAttributes:(NSDictionary **)dict;
|
- (id)initWithPath:(NSString *)path documentAttributes:(NSDictionary **)dict;
|
- (id)initWithRTF:(NSData *)data documentAttributes:(NSDictionary **)dict;
|
- (id)initWithRTFD:(NSData *)data documentAttributes:(NSDictionary **)dict;
|
- (id)initWithRTFDFileWrapper:(NSFileWrapper *)wrapper documentAttributes:(NSDictionary **)dict;
|
- (id)initWithString:(NSString *)str;
|
- (id)initWithString:(NSString *)str attributes:(NSDictionary *)attrs;
|
- (id)initWithURL:(NSURL *)url documentAttributes:(NSDictionary **)dict;
|
// Class Methods |
+ (NSAttributedString *)attributedStringWithAttachment:(NSTextAttachment *)attachment;
|
+ (NSArray *)textFileTypes;
|
+ (NSArray *)textPasteboardTypes;
|
+ (NSArray *)textUnfilteredFileTypes;
|
+ (NSArray *)textUnfilteredPasteboardTypes;
|
// Instance Methods |
- (NSFileWrapper *)RTFDFileWrapperFromRange:(NSRange)range documentAttributes:(NSDictionary *)dict;
|
- (NSData *)RTFDFromRange:(NSRange)range documentAttributes:(NSDictionary *)dict;
|
- (NSData *)RTFFromRange:(NSRange)range documentAttributes:(NSDictionary *)dict;
|
- (id)attribute:(NSString *)attrName atIndex:(unsigned int)location effectiveRange:(NSRangePointer)range;
|
- (id)attribute:(NSString *)attrName atIndex:(unsigned int)location longestEffectiveRange:(NSRangePointer)range
inRange:(NSRange)rangeLimit; inRange:(NSRange)rangeLimit;
|
- (NSAttributedString *)attributedSubstringFromRange:(NSRange)range;
|
- (NSDictionary *)attributesAtIndex:(unsigned)location effectiveRange:(NSRangePointer)range;
|
- (NSDictionary *)attributesAtIndex:(unsigned)location longestEffectiveRange:(NSRangePointer)range
inRange:(NSRange)rangeLimit;
|
- (BOOL)containsAttachments;
|
- (NSRange)doubleClickAtIndex:(unsigned)location;
|
- (void)drawAtPoint:(NSPoint)point;
|
- (void)drawInRect:(NSRect)rect;
|
- (NSDictionary *)fontAttributesInRange:(NSRange)range;
|
- (BOOL)isEqualToAttributedString:(NSAttributedString *)other;
|
- (unsigned)length;
|
- (unsigned)lineBreakBeforeIndex:(unsigned)location withinRange:(NSRange)aRange;
|
- (unsigned)nextWordFromIndex:(unsigned)location forward:(BOOL)isForward;
|
- (NSDictionary *)rulerAttributesInRange:(NSRange)range;
|
- (NSSize)size;
|
- (NSString *)string;
|
// Methods Implementing NSCoding |
- (void)encodeWithCoder:(NSCoder *)aCoder;
|
- (id)initWithCoder:(NSCoder *)aDecoder;
|
// Methods Implementing NSCopying |
- (id)copyWithZone:(NSZone *)zone;
|
// Methods Implementing NSMutableCopying |
- (id)mutableCopyWithZone:(NSZone *)zone;
|