- Core Foundation
Instances of CFAttributedString manage character strings and associated sets of attributes (for example, font and kerning information) that apply to individual characters or ranges of characters in the string. CFAttributedString as defined in Core Foundation provides the basic container functionality, while higher levels provide definitions for standard attributes, their values, and additional behaviors involving these. CFAttributedString represents an immutable string—use
CFMutable to create and manage an attributed string that can be changed after it has been created.
CFAttributedString is not a “subclass” of CFString; that is, it does not respond to CFString function calls. CFAttributedString conceptually contains a CFString to which it applies attributes. This protects you from ambiguities caused by the semantic differences between simple and attributed string.
Attributes are identified by key/value pairs stored in CFDictionary objects. Keys must be CFString objects, while the corresponding values are CFType objects of an appropriate type. See the attribute constants in NSAttributedString Application Kit Additions Reference or NSAttributedString UIKit Additions Reference for standard attribute names.
CFAttributedString is “toll-free bridged” with its Foundation counterpart,
NSAttributed. This means that the Core Foundation type is interchangeable in function or method calls with the bridged Foundation object. Therefore, in a method where you see an
NSAttributed parameter, you can pass in a
CFAttributed, and in a function where you see a
CFAttributed parameter, you can pass in an
NSAttributed instance. This also applies to concrete subclasses of
NSAttributed. See Toll-Free Bridged Types for more information on toll-free bridging.