Instance Method

initWithString:attributes:

Returns an NSAttributedString object initialized with a given string and attributes.

Declaration

- (instancetype)initWithString:(NSString *)str attributes:(NSDictionary<NSAttributedStringKey, id> *)attrs;

Parameters

aString

The string for the new attributed string.

attributes

The attributes for the new attributed string. For a list of attributes that you can include in this dictionary, see Character Attributes.

Discussion

Returns an NSAttributedString object initialized with the characters of aString and the attributes of attributes. The returned object might be different from the original receiver.

See Also

Creating an NSAttributedString Object

- initWithString:

Returns an NSAttributedString object initialized with the characters of a given string and no attribute information.

- initWithAttributedString:

Returns an NSAttributedString object initialized with the characters and attributes of another given attributed string.

- initWithData:options:documentAttributes:error:

Initializes and returns a new attributed string object from the data contained in the given data object.

- initWithDocFormat:documentAttributes:

Initializes and returns a new NSAttributedString object from Microsoft Word format data contained in the given NSData object.

- initWithHTML:documentAttributes:

Initializes and returns a new NSAttributedString object from HTML contained in the given data object.

- initWithHTML:baseURL:documentAttributes:

Initializes and returns a new NSAttributedString object from the HTML contained in the given object and base URL.

- initWithHTML:options:documentAttributes:

Initializes and returns a new attributed string object from HTML contained in the given data object.

- initWithRTF:documentAttributes:

Initializes a new attributed string object by decoding the stream of RTF commands and data contained in the given data object.

- initWithRTFD:documentAttributes:

Initializes a new attributed string object by decoding the stream of RTFD commands and data contained in the given data object.

- initWithRTFDFileWrapper:documentAttributes:

Initializes a new attributed string object from the specified file wrapper containing an RTFD document.

- initWithURL:options:documentAttributes:error:

Initializes a new NSAttributedString object from the contents of the given URL.

+ attributedStringWithAttachment:

Creates an attributed string with an attachment.