Initializer

init(string:attributes:)

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

Declaration

init(string str: String, attributes attrs: [NSAttributedString.Key : Any]? = nil)

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

init(string: String)

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

init(attributedString: NSAttributedString)

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

init(data: Data, options: [NSAttributedString.DocumentReadingOptionKey : Any], documentAttributes: AutoreleasingUnsafeMutablePointer<NSDictionary?>?)

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

init?(docFormat: Data, documentAttributes: AutoreleasingUnsafeMutablePointer<NSDictionary?>?)

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

init?(html: Data, documentAttributes: AutoreleasingUnsafeMutablePointer<NSDictionary?>?)

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

init?(html: Data, baseURL: URL, documentAttributes: AutoreleasingUnsafeMutablePointer<NSDictionary?>?)

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

init?(html: Data, options: [NSAttributedString.DocumentReadingOptionKey : Any], documentAttributes: AutoreleasingUnsafeMutablePointer<NSDictionary?>?)

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

init?(rtf: Data, documentAttributes: AutoreleasingUnsafeMutablePointer<NSDictionary?>?)

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

init?(rtfd: Data, documentAttributes: AutoreleasingUnsafeMutablePointer<NSDictionary?>?)

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

init?(rtfdFileWrapper: FileWrapper, documentAttributes: AutoreleasingUnsafeMutablePointer<NSDictionary?>?)

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

init(attachment: NSTextAttachment)

Creates an attributed string with an attachment.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software