CFString
Declaration
class CFStringOverview
CFString provides a suite of efficient string-manipulation and string-conversion functions. It offers seamless Unicode support and facilitates the sharing of data between Cocoa and C-based programs. CFString objects are immutable—use CFMutableString to create and manage a string that can be changed after it has been created.
CFString has two primitive functions, CFStringGetLength(_:) and CFStringGetCharacterAtIndex(_:_:), that provide the basis for all other functions in its interface. The CFStringGetLength function returns the total number (in terms of UTF-16 code pairs) of characters in the string. The CFStringGetCharacterAtIndex function gives access to each character in the string by index, with index values starting at 0.
CFString provides functions for finding and comparing strings. It also provides functions for reading numeric values from strings, for combining strings in various ways, and for converting a string to different forms (such as encoding and case changes). A number of functions, for example CFStringFindWithOptions, allow you to specify a range over which to operate within a string. The specified range must not exceed the length of the string. Debugging options may help you to catch any errors that arise if a range does exceed a string’s length.
Like other Core Foundation types, you can hash CFStrings using the CFHash(_:) function. You should never, though, store a hash value outside of your application and expect it to be useful if you read it back in later (hash values may change between different releases of the operating system).
CFString is “toll-free bridged” with its Cocoa Foundation counterpart, NSString. 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 NSString * parameter, you can pass in a CFStringRef, and in a function where you see a CFStringRef parameter, you can pass in an NSString instance. This also applies to concrete subclasses of NSString. See Toll-Free Bridged Types for more information on toll-free bridging.
Topics
Creating a CFString
CFStringCreateArrayBySeparatingStrings(_:_:_:)CFStringCreateByCombiningStrings(_:_:_:)CFStringCreateCopy(_:_:)CFStringCreateFromExternalRepresentation(_:_:_:)CFStringCreateWithBytes(_:_:_:_:_:)CFStringCreateWithBytesNoCopy(_:_:_:_:_:_:)CFStringCreateWithCharacters(_:_:_:)CFStringCreateWithCharactersNoCopy(_:_:_:_:)CFStringCreateWithCString(_:_:_:)CFStringCreateWithCStringNoCopy(_:_:_:_:)CFStringCreateWithFormatAndArguments(_:_:_:_:)CFStringCreateWithPascalString(_:_:_:)CFStringCreateWithPascalStringNoCopy(_:_:_:_:)CFStringCreateWithSubstring(_:_:_:)
Searching Strings
CFStringCreateArrayWithFindResults(_:_:_:_:_:)CFStringFind(_:_:_:)CFStringFindCharacterFromSet(_:_:_:_:_:)CFStringFindWithOptions(_:_:_:_:_:)CFStringFindWithOptionsAndLocale(_:_:_:_:_:_:)CFStringGetLineBounds(_:_:_:_:_:)
Comparing Strings
CFStringCompare(_:_:_:)CFStringCompareWithOptions(_:_:_:_:)CFStringCompareWithOptionsAndLocale(_:_:_:_:_:)CFStringHasPrefix(_:_:)CFStringHasSuffix(_:_:)
Accessing Characters
CFStringCreateExternalRepresentation(_:_:_:_:)CFStringGetBytes(_:_:_:_:_:_:_:_:)CFStringGetCharacterAtIndex(_:_:)CFStringGetCharacters(_:_:_:)CFStringGetCharactersPtr(_:)CFStringGetCharacterFromInlineBuffer(_:_:)CFStringGetCString(_:_:_:_:)CFStringGetCStringPtr(_:_:)CFStringGetLength(_:)CFStringGetPascalString(_:_:_:_:)CFStringGetPascalStringPtr(_:_:)CFStringGetRangeOfComposedCharactersAtIndex(_:_:)CFStringInitInlineBuffer(_:_:_:)
Working With Hyphenation
Working With Encodings
CFStringConvertEncodingToIANACharSetName(_:)CFStringConvertEncodingToNSStringEncoding(_:)CFStringConvertEncodingToWindowsCodepage(_:)CFStringConvertIANACharSetNameToEncoding(_:)CFStringConvertNSStringEncodingToEncoding(_:)CFStringConvertWindowsCodepageToEncoding(_:)CFStringGetFastestEncoding(_:)CFStringGetListOfAvailableEncodings()CFStringGetMaximumSizeForEncoding(_:_:)CFStringGetMostCompatibleMacStringEncoding(_:)CFStringGetNameOfEncoding(_:)CFStringGetSmallestEncoding(_:)CFStringGetSystemEncoding()CFStringIsEncodingAvailable(_:)
Getting Numeric Values
Getting String Properties
String File System Representations
CFStringCreateWithFileSystemRepresentation(_:_:)CFStringGetFileSystemRepresentation(_:_:_:)CFStringGetMaximumSizeOfFileSystemRepresentation(_:)
Getting Paragraph Bounds
Managing Surrogates
CFStringGetLongCharacterForSurrogatePair(_:_:)CFStringGetSurrogatePairForLongCharacter(_:_:)CFStringIsSurrogateHighCharacter(_:)CFStringIsSurrogateLowCharacter(_:)
Data Types
Constants
See Also
Related Documentation
- Property List Programming Topics for Core Foundation
- Data Formatting Guide for Core Foundation
- String Programming Guide for Core Foundation