CFStringCreateWithFormat

Header: CFString.h Carbon status: Supported

Creates an immutable CFString object from a formatted string and a variable number of arguments.

CFStringRef CFStringCreateWithFormat (
    CFAllocatorRef alloc, 
    CFDictionaryRef formatOptions, 
    CFStringRef format,
    ...
);
Parameter descriptions
alloc

Pass a reference to an allocator to be used to create the CFString object or pass NULL to request the default allocator.

formatOptions

Pass a reference to a CFDictionary object containing formatting options for the string (such as the thousand-separator character, which is dependent on locale). Currently, these options are an unimplemented feature.

format

Pass a reference to a CFString object that contains a string with printf-style specifiers.

function result

A reference to an immutable CFString object or NULL if there was a problem creating the object.

DISCUSSION

The CFStringCreateWithFormat creates a CFString object from another CFString object containing a formatted string and a list of arguments. A formatted string is one with printf-style format specifiers embedded in the text such as %d (decimal), %f (double), and %@ (Core Foundation object). The subsequent arguments, in order, are substituted for the specifiers in the character data contained by the created object. You can also reorder the arguments in the string by using modifiers of the form"$n" with the format specifiers (for example, %$2d. These modifiers allow you to easily localize formatted strings by reading them from resources or property-list files.

For more information on supported specifiers, see the relevant section in "Core Foundation String Services Tasks."

AVAILABILITY

Supported in Carbon. Available in Carbon 1.0.2 and later.


© 2000 Apple Computer, Inc. (Last Updated 6/30/2000)