CFAttributedString
Declaration
class CFAttributedStringOverview
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 CFMutableAttributedString 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, NSAttributedString. 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 NSAttributedString * parameter, you can pass in a CFAttributedStringRef, and in a function where you see a CFAttributedStringRef parameter, you can pass in an NSAttributedString instance. This also applies to concrete subclasses of NSAttributedString. See Toll-Free Bridged Types for more information on toll-free bridging.
Topics
Creating a CFAttributedString
CFAttributedStringCreate(_:_:_:)CFAttributedStringCreateCopy(_:_:)CFAttributedStringCreateWithSubstring(_:_:_:)CFAttributedStringGetLength(_:)CFAttributedStringGetString(_:)
Accessing Attributes
CFAttributedStringGetAttribute(_:_:_:_:)CFAttributedStringGetAttributes(_:_:_:)CFAttributedStringGetAttributeAndLongestEffectiveRange(_:_:_:_:_:)CFAttributedStringGetAttributesAndLongestEffectiveRange(_:_:_:_:)
Getting Attributed String Properties
See Also
Related Documentation
- Property List Programming Topics for Core Foundation
- String Programming Guide for Core Foundation
- Data Formatting Guide for Core Foundation