Inherits from | |
Framework | /System/Library/Frameworks/AppKit.framework |
Companion guide | |
Declared in | NSAttributedString.h NSTextAttachment.h |
Additions to the NSMutableAttributedString class primarily involve setting graphical attributes, such as font, super- or subscripting, and alignment, and making these attributes consistent after changes.
– applyFontTraits:range:
– setAlignment:range:
– setBaseWritingDirection:range:
– subscriptRange:
– superscriptRange:
– unscriptRange:
– fixAttributesInRange:
– fixAttachmentAttributeInRange:
– fixFontAttributeInRange:
– fixParagraphStyleAttributeInRange:
– readFromData:options:documentAttributes:
– readFromData:options:documentAttributes:error:
– readFromURL:options:documentAttributes:
– readFromURL:options:documentAttributes:error:
Applies the font attributes specified by mask to the characters in aRange.
- (void)applyFontTraits:(NSFontTraitMask)mask range:(NSRange)aRange
See the NSFontManager class specification for a description of the font traits available. Raises an NSRangeException
if any part of aRange lies beyond the end of the receiver’s characters.
NSAttributedString.h
Cleans up attachment attributes in aRange, removing all attachment attributes assigned to characters other than NSAttachmentCharacter
.
- (void)fixAttachmentAttributeInRange:(NSRange)aRange
Raises an NSRangeException
if any part of aRange lies beyond the end of the receiver’s characters.
NSAttributedString.h
Invokes the other fix...
methods, allowing you to clean up an attributed string with a single message.
- (void)fixAttributesInRange:(NSRange)aRange
Raises an NSRangeException
if any part of aRange lies beyond the end of the receiver’s characters.
NSAttributedString.h
Fixes the font attribute in aRange, assigning default fonts to characters with illegal fonts for their scripts and otherwise correcting font attribute assignments.
- (void)fixFontAttributeInRange:(NSRange)aRange
For example, Kanji characters assigned a Latin font are reassigned an appropriate Kanji font. Raises an NSRangeException
if any part of aRange lies beyond the end of the receiver’s characters.
NSAttributedString.h
Fixes the paragraph style attributes in aRange, assigning the first paragraph style attribute value in each paragraph to all characters of the paragraph.
- (void)fixParagraphStyleAttributeInRange:(NSRange)aRange
This method extends the range as needed to cover the last paragraph partially contained. A paragraph is delimited by any of these characters, the longest possible sequence being preferred to any shorter:
U+000D (\r
or CR)
U+000A (\n
or LF)
U+2028 (Unicode line separator)
U+2029 (Unicode paragraph separator) \r\n
, in that order (also known as CRLF)
Raises an NSRangeException
if any part of aRange lies beyond the end of the receiver’s characters.
NSAttributedString.h
Sets the contents of the receiver from the stream at data.
- (BOOL)readFromData:(NSData *)data options:(NSDictionary *)options documentAttributes:(NSDictionary **)dict
options can contain one of the values described in the “Constants” section of NSAttributedString Additions ("Option keys for importing documents").
On return, the documentAttributes dictionary (if provided) contains the various keys described in the “Constants” section of NSAttributedString Additions.
NSAttributedString.h
Sets the contents of the receiver from the stream at data.
- (BOOL)readFromData:(NSData *)data options:(NSDictionary *)opts documentAttributes:(NSDictionary **)dict error:(NSError **)error
opts can contain one of the values described in the “Constants” section of NSAttributedString Additions ("Option keys for importing documents").
On return, the documentAttributes dictionary (if provided) contains the various keys described in the “Constants” section of NSAttributedString Additions. If unsuccessful, returns NO , after setting error to point to an NSError that encapsulates the reason why the attributed string object could not be created.
NSAttributedString.h
Sets the contents of receiver from the file at url.
- (BOOL)readFromURL:(NSURL *)url options:(NSDictionary *)options documentAttributes:(NSDictionary **)documentAttributes
Filter services can be used to convert the contents of the URL into a format recognized by Cocoa. options can contain one of the values described in the “Constants” section of NSAttributedString Additions ("Option keys for importing documents").
On return, the documentAttributes dictionary (if provided) contains the various keys described in the “Constants” section of NSAttributedString Additions.
NSAttributedString.h
Sets the contents of receiver from the file at url.
- (BOOL)readFromURL:(NSURL *)url options:(NSDictionary *)opts documentAttributes:(NSDictionary **)dict error:(NSError **)error
Filter services can be used to convert the contents of the URL into a format recognized by Cocoa. opts can contain one of the values described in the “Constants” section of NSAttributedString Additions ("Option keys for importing documents").
On return, the dict dictionary (if provided) contains the various keys described in the “Constants” section of NSAttributedString Additions. If unsuccessful, returns NO , after setting error to point to an NSError that encapsulates the reason why the attributed string object could not be created.
NSAttributedString.h
Sets the alignment characteristic of the paragraph style attribute for the characters in aRange to alignment.
- (void)setAlignment:(NSTextAlignment)alignment range:(NSRange)aRange
When attribute fixing takes place, this change will affect only paragraphs whose first character was included in aRange. Raises an NSRangeException
if any part of aRange lies beyond the end of the receiver’s characters.
NSAttributedString.h
Sets the base writing direction for the characters in range to writingDirection.
- (void)setBaseWritingDirection:(NSWritingDirection)writingDirection range:(NSRange)range
NSAttributedString.h
Decrements the value of the superscript attribute for characters in aRange by 1.
- (void)subscriptRange:(NSRange)aRange
Raises an NSRangeException
if any part of aRange lies beyond the end of the receiver’s characters.
NSAttributedString.h
Increments the value of the superscript attribute for characters in aRange by 1.
- (void)superscriptRange:(NSRange)aRange
Raises an NSRangeException
if any part of aRange lies beyond the end of the receiver’s characters.
NSAttributedString.h
Removes the superscript attribute from the characters in aRange.
- (void)unscriptRange:(NSRange)aRange
Raises an NSRangeException
if any part of aRange lies beyond the end of the receiver’s characters.
NSAttributedString.h
Updates all attachments based on files contained in the RTFD file package at path.
- (void)updateAttachmentsFromPath:(NSString *)path
– updateFromPath:
(NSFileWrapper
)NSTextAttachment.h
© 2006 Apple Computer, Inc. All Rights Reserved. (Last updated: 2006-05-23)